diff --git a/libvirt-0.7.7-audio-config.patch b/libvirt-0.7.7-audio-config.patch new file mode 100644 index 0000000..7e63dfb --- /dev/null +++ b/libvirt-0.7.7-audio-config.patch @@ -0,0 +1,163 @@ +commit 377bc412ce10845930346744e30fe9c4790e5e63 +Author: Cole Robinson +Date: Wed May 19 16:03:52 2010 -0400 + + daemon: Export SDL audio environment variables + + /etc/sysconfig/libvirtd has a few environment variables for configuring + libvirt SDL audio. The libvirtd process doesn't see these, however, because + they are never exported. Let's export the variables after sourcing the + sysconfig script. + + There is another problem here that the commented out values in the + sysconfig script are not neccessarily the actual defaults, we are qemus + mercy here. Not sure how to solve that. + +diff --git a/daemon/libvirtd.init.in b/daemon/libvirtd.init.in +index 809433e..aa7870c 100644 +--- a/daemon/libvirtd.init.in ++++ b/daemon/libvirtd.init.in +@@ -45,6 +45,9 @@ KRB5_KTNAME=/etc/libvirt/krb5.tab + + test -f @sysconfdir@/sysconfig/libvirtd && . @sysconfdir@/sysconfig/libvirtd + ++export QEMU_AUDIO_DRV ++export SDL_AUDIODRIVER ++ + LIBVIRTD_CONFIG_ARGS= + if [ -n "$LIBVIRTD_CONFIG" ] + then +commit 7f44743c524faa493d05eaf026f1e90a807e502b +Author: Cole Robinson +Date: Wed May 26 10:51:36 2010 -0400 + + daemon: sysconf: Update comment about VNC audio + +diff --git a/daemon/libvirtd.sysconf b/daemon/libvirtd.sysconf +index 28080a0..b730c5e 100644 +--- a/daemon/libvirtd.sysconf ++++ b/daemon/libvirtd.sysconf +@@ -11,7 +11,8 @@ + # Override the QEMU/SDL default audio driver probing when + # starting virtual machines using SDL graphics + # +-# NB these have no effect for VMs using VNC ++# NB these have no effect for VMs using VNC, unless vnc_allow_host_audio ++# is enabled in /etc/libvirt/qemu.conf + #QEMU_AUDIO_DRV=sdl + # + #SDL_AUDIODRIVER=pulse +commit fb3ebd0397980ae035e66f0008b09e13377ef80f +Author: Cole Robinson +Date: Wed May 19 16:41:01 2010 -0400 + + qemu: Allow using regular audio backends with VNC + + Currently all host audio backends are disabled if a VM is using VNC, in + favor of the QEMU VNC audio extension. Unfortunately no released VNC + client supports this extension, so users have no way of getting audio + to work if using VNC. + + Add a new config option in qemu.conf which allows changing libvirt's + behavior, but keep the default intact. + + v2: Fix doc typos, change name to vnc_allow_host_audio + +diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug +index 5bd60b3..551cc20 100644 +--- a/src/qemu/libvirtd_qemu.aug ++++ b/src/qemu/libvirtd_qemu.aug +@@ -38,6 +38,7 @@ module Libvirtd_qemu = + | str_entry "save_image_format" + | str_entry "hugetlbfs_mount" + | bool_entry "relaxed_acs_check" ++ | bool_entry "vnc_allow_host_audio" + + (* Each enty in the config is one of the following three ... *) + let entry = vnc_entry +diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf +index 3da332f..98a1176 100644 +--- a/src/qemu/qemu.conf ++++ b/src/qemu/qemu.conf +@@ -168,3 +168,13 @@ + # be assigned to guests. + # + # relaxed_acs_check = 1 ++ ++ ++# QEMU implements an extension for providing audio over a VNC connection, ++# though if your VNC client does not support it, your only chance for getting ++# sound output is through regular audio backends. By default, libvirt will ++# disable all QEMU sound backends if using VNC, since they can cause ++# permissions issues. Enabling this option will make libvirtd honor the ++# QEMU_AUDIO_DRV environment variable when using VNC. ++# ++# vnc_allow_host_audio = 0 +diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c +index 2755545..b4d8e74 100644 +--- a/src/qemu/qemu_conf.c ++++ b/src/qemu/qemu_conf.c +@@ -351,6 +351,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, + CHECK_TYPE ("relaxed_acs_check", VIR_CONF_LONG); + if (p) driver->relaxedACS = p->l; + ++ p = virConfGetValue (conf, "vnc_allow_host_audio"); ++ CHECK_TYPE ("vnc_allow_host_audio", VIR_CONF_LONG); ++ if (p) driver->vncAllowHostAudio = p->l; ++ + virConfFree (conf); + return 0; + } +@@ -4399,12 +4403,15 @@ int qemudBuildCommandLine(virConnectPtr conn, + ADD_ARG_LIT(def->graphics[0]->data.vnc.keymap); + } + +- /* QEMU implements a VNC extension for providing audio, so we +- * set the audio backend to none, to prevent it opening the +- * host OS audio devices since that causes security issues +- * and is non-sensical when using VNC. ++ /* Unless user requested it, set the audio backend to none, to ++ * prevent it opening the host OS audio devices, since that causes ++ * security issues and might not work when using VNC. + */ +- ADD_ENV_LIT("QEMU_AUDIO_DRV=none"); ++ if (driver->vncAllowHostAudio) { ++ ADD_ENV_COPY("QEMU_AUDIO_DRV"); ++ } else { ++ ADD_ENV_LIT("QEMU_AUDIO_DRV=none"); ++ } + } else if ((def->ngraphics == 1) && + def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { + char *xauth = NULL; +diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h +index 8fd8d79..7fb4de5 100644 +--- a/src/qemu/qemu_conf.h ++++ b/src/qemu/qemu_conf.h +@@ -138,6 +138,8 @@ struct qemud_driver { + + unsigned int relaxedACS : 1; + ++ unsigned int vncAllowHostAudio : 1; ++ + virCapsPtr caps; + + /* An array of callbacks */ +diff --git a/src/qemu/test_libvirtd_qemu.aug b/src/qemu/test_libvirtd_qemu.aug +index 2feedc0..a048ae5 100644 +--- a/src/qemu/test_libvirtd_qemu.aug ++++ b/src/qemu/test_libvirtd_qemu.aug +@@ -97,6 +97,8 @@ save_image_format = \"gzip\" + hugetlbfs_mount = \"/dev/hugepages\" + + relaxed_acs_check = 1 ++ ++vnc_allow_host_audio = 1 + " + + test Libvirtd_qemu.lns get conf = +@@ -204,3 +206,5 @@ relaxed_acs_check = 1 + { "hugetlbfs_mount" = "/dev/hugepages" } + { "#empty" } + { "relaxed_acs_check" = "1" } ++{ "#empty" } ++{ "vnc_allow_host_audio" = "1" } diff --git a/libvirt-0.7.7-caps-option.patch b/libvirt-0.7.7-caps-option.patch new file mode 100644 index 0000000..afb660b --- /dev/null +++ b/libvirt-0.7.7-caps-option.patch @@ -0,0 +1,110 @@ +diff -rup libvirt-0.7.7/src/qemu/libvirtd_qemu.aug new/src/qemu/libvirtd_qemu.aug +--- libvirt-0.7.7/src/qemu/libvirtd_qemu.aug 2010-06-17 12:38:52.998946000 -0400 ++++ new/src/qemu/libvirtd_qemu.aug 2010-06-17 12:39:28.504148000 -0400 +@@ -39,6 +39,7 @@ module Libvirtd_qemu = + | str_entry "hugetlbfs_mount" + | bool_entry "relaxed_acs_check" + | bool_entry "vnc_allow_host_audio" ++ | bool_entry "clear_emulator_capabilities" + + (* Each enty in the config is one of the following three ... *) + let entry = vnc_entry +diff -rup libvirt-0.7.7/src/qemu/qemu.conf new/src/qemu/qemu.conf +--- libvirt-0.7.7/src/qemu/qemu.conf 2010-06-17 12:38:53.001953000 -0400 ++++ new/src/qemu/qemu.conf 2010-06-17 12:39:28.508149000 -0400 +@@ -178,3 +178,12 @@ + # QEMU_AUDIO_DRV environment variable when using VNC. + # + # vnc_allow_host_audio = 0 ++ ++# If clear_emulator_capabilities is enabled, libvirt will drop all ++# privileged capabilities of the QEmu/KVM emulator. This is enabled by ++# default. ++# ++# Warning: Disabling this option means that a compromised guest can ++# exploit the privileges and possibly do damage to the host. ++# ++# clear_emulator_capabilities = 1 +diff -rup libvirt-0.7.7/src/qemu/qemu_conf.c new/src/qemu/qemu_conf.c +--- libvirt-0.7.7/src/qemu/qemu_conf.c 2010-06-17 12:38:53.010946000 -0400 ++++ new/src/qemu/qemu_conf.c 2010-06-17 12:39:28.526151000 -0400 +@@ -103,6 +103,7 @@ int qemudLoadDriverConfig(struct qemud_d + + /* Setup critical defaults */ + driver->dynamicOwnership = 1; ++ driver->clearEmulatorCapabilities = 1; + + if (!(driver->vncListen = strdup("127.0.0.1"))) { + virReportOOMError(); +@@ -354,6 +355,10 @@ int qemudLoadDriverConfig(struct qemud_d + CHECK_TYPE ("vnc_allow_host_audio", VIR_CONF_LONG); + if (p) driver->vncAllowHostAudio = p->l; + ++ p = virConfGetValue (conf, "clear_emulator_capabilities"); ++ CHECK_TYPE ("clear_emulator_capabilities", VIR_CONF_LONG); ++ if (p) driver->clearEmulatorCapabilities = p->l; ++ + virConfFree (conf); + return 0; + } +diff -rup libvirt-0.7.7/src/qemu/qemu_conf.h new/src/qemu/qemu_conf.h +--- libvirt-0.7.7/src/qemu/qemu_conf.h 2010-06-17 12:38:53.015945000 -0400 ++++ new/src/qemu/qemu_conf.h 2010-06-17 12:39:28.531146000 -0400 +@@ -129,8 +129,8 @@ struct qemud_driver { + ebtablesContext *ebtables; + + unsigned int relaxedACS : 1; +- + unsigned int vncAllowHostAudio : 1; ++ unsigned int clearEmulatorCapabilities : 1; + + virCapsPtr caps; + +diff -rup libvirt-0.7.7/src/qemu/qemu_driver.c new/src/qemu/qemu_driver.c +--- libvirt-0.7.7/src/qemu/qemu_driver.c 2010-06-17 12:38:52.988953000 -0400 ++++ new/src/qemu/qemu_driver.c 2010-06-17 12:39:28.542147000 -0400 +@@ -2699,7 +2699,7 @@ static int qemudStartVMDaemon(virConnect + int stdin_fd) { + const char **argv = NULL, **tmp; + const char **progenv = NULL; +- int i, ret; ++ int i, ret, runflags; + struct stat sb; + int *tapfds = NULL; + int ntapfds = 0; +@@ -2893,9 +2893,16 @@ static int qemudStartVMDaemon(virConnect + for (i = 0 ; i < ntapfds ; i++) + FD_SET(tapfds[i], &keepfd); + ++ VIR_DEBUG("Clear emulator capabilities: %d", ++ driver->clearEmulatorCapabilities); ++ runflags = VIR_EXEC_NONBLOCK; ++ if (driver->clearEmulatorCapabilities) { ++ runflags |= VIR_EXEC_CLEAR_CAPS; ++ } ++ + ret = virExecDaemonize(argv, progenv, &keepfd, &child, + stdin_fd, &logfile, &logfile, +- VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS, ++ runflags, + qemudSecurityHook, &hookData, + pidfile); + VIR_FREE(pidfile); +diff -rup libvirt-0.7.7/src/qemu/test_libvirtd_qemu.aug new/src/qemu/test_libvirtd_qemu.aug +--- libvirt-0.7.7/src/qemu/test_libvirtd_qemu.aug 2010-06-17 12:38:53.018948000 -0400 ++++ new/src/qemu/test_libvirtd_qemu.aug 2010-06-17 12:39:28.546145000 -0400 +@@ -99,6 +99,8 @@ hugetlbfs_mount = \"/dev/hugepages\" + relaxed_acs_check = 1 + + vnc_allow_host_audio = 1 ++ ++clear_emulator_capabilities = 0 + " + + test Libvirtd_qemu.lns get conf = +@@ -208,3 +210,5 @@ vnc_allow_host_audio = 1 + { "relaxed_acs_check" = "1" } + { "#empty" } + { "vnc_allow_host_audio" = "1" } ++{ "#empty" } ++{ "clear_emulator_capabilities" = "0" } diff --git a/libvirt-0.7.7-fix-usb-parsing.patch b/libvirt-0.7.7-fix-usb-parsing.patch new file mode 100644 index 0000000..fb26220 --- /dev/null +++ b/libvirt-0.7.7-fix-usb-parsing.patch @@ -0,0 +1,12 @@ +diff -rup libvirt-0.7.1/src/util/hostusb.c new/src/hostusb.c +--- libvirt-0.7.1/src/util/hostusb.c 2010-06-03 13:51:14.392459000 -0400 ++++ new/src/util/hostusb.c 2010-06-03 14:49:11.763379000 -0400 +@@ -123,7 +123,7 @@ static int usbFindBusByVendor(virConnect + char *tmpstr = de->d_name; + unsigned found_bus, found_addr; + +- if (STREQ(de->d_name, "usb")) ++ if (STRPREFIX(de->d_name, "usb")) + tmpstr += 3; + + if (virStrToLong_ui(tmpstr, &ignore, 10, &found_bus) < 0) { diff --git a/libvirt-0.7.7-init-fixes.patch b/libvirt-0.7.7-init-fixes.patch new file mode 100644 index 0000000..4926f46 --- /dev/null +++ b/libvirt-0.7.7-init-fixes.patch @@ -0,0 +1,35 @@ +commit 9d0adf249827dde9e1c0d1c19513cf6018ceb34e +Author: Cole Robinson +Date: Wed May 19 15:57:56 2010 -0400 + + daemon: A few initscript corrections + + Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=565238 + + - Avahi service is called 'avahi-daemon' + - chkconfig descriptions must use \ for line continuations + +diff --git a/daemon/libvirtd.init.in b/daemon/libvirtd.init.in +index d4dc98b..809433e 100644 +--- a/daemon/libvirtd.init.in ++++ b/daemon/libvirtd.init.in +@@ -9,7 +9,7 @@ + # Should-Start: $named + # Should-Start: xend + # Should-Start: hal +-# Should-Start: avahi ++# Should-Start: avahi-daemon + # Required-Stop: $network messagebus + # Should-Stop: $named + # Default-Start: 3 4 5 +@@ -24,8 +24,8 @@ + # libvirtd: guest and virtual network management daemon + # + # chkconfig: 345 97 03 +-# description: This is a daemon for managing guest instances +-# and libvirt virtual networks ++# description: This is a daemon for managing guest instances \ ++# and libvirt virtual networks \ + # See http://libvirt.org + # + # processname: libvirtd diff --git a/libvirt-0.7.7-man-page-list.patch b/libvirt-0.7.7-man-page-list.patch new file mode 100644 index 0000000..b6a543c --- /dev/null +++ b/libvirt-0.7.7-man-page-list.patch @@ -0,0 +1,65 @@ +commit e5f31f461f63bbad211e84b810d6ba43a705f9dd +Author: Justin Clift +Date: Sun May 30 13:28:42 2010 +1000 + + Trivial virsh.pod additions --all for "list" command and similar + + This is just a trivial patch to virsh.pod (from git master). It adds the + following pieces to the virsh man page: + + + Shows the --inactive and --all optional parameters for the list + command. + + Closes Bugzilla #575512, reported by Renich Bon Ciric + https://bugzilla.redhat.com/show_bug.cgi?id=575512 + + + Corrects the existing description of the list command, to now say + that only running domains are listed if no domains are specified. + + The man page up until this point has said all domains are listed if + no domains are specified, which is incorrect. + + + Adds the "shut off" state to the list of states for the list + command. + + + Adds a missing =back around line 755, that pod2man was complaining + was missing. + +diff --git a/tools/virsh.pod b/tools/virsh.pod +index cf7585d..495bb46 100644 +--- a/tools/virsh.pod ++++ b/tools/virsh.pod +@@ -156,10 +156,10 @@ description see: + L + The XML also show the NUMA topology information if available. + +-=item B ++=item B optional I<--inactive> I<--all> + + Prints information about one or more domains. If no domains are +-specified it prints out information about all domains. ++specified it prints out information about running domains. + + An example format for the list is as follows: + +@@ -177,7 +177,7 @@ State is the run state (see below). + + B + +-The State field lists 6 states for a domain, and which ones the ++The State field lists 7 states for a domain, and which ones the + current domain is in. + + =over 4 +@@ -205,6 +205,11 @@ The domain is in the process of shutting down, i.e. the guest operating system + has been notified and should be in the process of stopping its operations + gracefully. + ++=item B ++ ++The domain is not running. Usually this indicates the domain has been ++shut down completely, or has not been started. ++ + =item B + + The domain has crashed, which is always a violent ending. Usually diff --git a/libvirt-0.7.7-network-collision.patch b/libvirt-0.7.7-network-collision.patch new file mode 100644 index 0000000..6ae89be --- /dev/null +++ b/libvirt-0.7.7-network-collision.patch @@ -0,0 +1,169 @@ +commit a83fe2c23efad190a1e00e448f607fe032650fd6 +Author: Cole Robinson +Date: Thu May 20 19:31:16 2010 -0400 + + network: bridge: Don't start network if it collides with host routing + + Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=235961 + + If using the default virtual network, an easy way to lose guest network + connectivity is to install libvirt inside the VM. The autostarted + default network inside the guest collides with host virtual network + routing. This is a long standing issue that has caused users quite a + bit of pain and confusion. + + On network startup, parse /proc/net/route and compare the requested + IP+netmask against host routing destinations: if any matches are found, + refuse to start the network. + + v2: Drop sscanf, fix a comment typo, comment that function could use + libnl instead of /proc + + v3: Consider route netmask. Compare binary data rather than convert to + string. + + v4: Return to using sscanf, drop inet functions in favor of virSocket, + parsing safety checks. Don't make parse failures fatal, in case + expected format changes. + + v5: Try and continue if we receive unexpected. Delimit parsed lines to + prevent scanning past newline + +diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c +index 5d7ef19..7ab3f3e 100644 +--- a/src/network/bridge_driver.c ++++ b/src/network/bridge_driver.c +@@ -57,6 +57,7 @@ + #include "iptables.h" + #include "bridge.h" + #include "logging.h" ++#include "util/network.h" + + #define NETWORK_PID_DIR LOCAL_STATE_DIR "/run/libvirt/network" + #define NETWORK_STATE_DIR LOCAL_STATE_DIR "/lib/libvirt/network" +@@ -908,6 +909,114 @@ cleanup: + return ret; + } + ++#define PROC_NET_ROUTE "/proc/net/route" ++ ++/* XXX: This function can be a lot more exhaustive, there are certainly ++ * other scenarios where we can ruin host network connectivity. ++ * XXX: Using a proper library is preferred over parsing /proc ++ */ ++static int networkCheckRouteCollision(virNetworkObjPtr network) ++{ ++ int ret = -1, len; ++ unsigned int net_dest; ++ char *cur, *buf = NULL; ++ enum {MAX_ROUTE_SIZE = 1024*64}; ++ virSocketAddr inaddress, innetmask; ++ ++ if (!network->def->ipAddress || !network->def->netmask) ++ return 0; ++ ++ if (virSocketParseAddr(network->def->ipAddress, &inaddress, 0) < 0) { ++ networkReportError(VIR_ERR_INTERNAL_ERROR, ++ _("cannot parse IP address '%s'"), ++ network->def->ipAddress); ++ goto error; ++ } ++ ++ if (virSocketParseAddr(network->def->netmask, &innetmask, 0) < 0) { ++ networkReportError(VIR_ERR_INTERNAL_ERROR, ++ _("cannot parse netmask '%s'"), ++ network->def->netmask); ++ goto error; ++ } ++ ++ if (inaddress.stor.ss_family != AF_INET || ++ innetmask.stor.ss_family != AF_INET) { ++ /* Only support collision check for IPv4 */ ++ goto out; ++ } ++ ++ net_dest = (inaddress.inet4.sin_addr.s_addr & ++ innetmask.inet4.sin_addr.s_addr); ++ ++ /* Read whole routing table into memory */ ++ if ((len = virFileReadAll(PROC_NET_ROUTE, MAX_ROUTE_SIZE, &buf)) < 0) ++ goto error; ++ ++ /* Dropping the last character shouldn't hurt */ ++ if (len > 0) ++ buf[len-1] = '\0'; ++ ++ VIR_DEBUG("%s output:\n%s", PROC_NET_ROUTE, buf); ++ ++ if (!STRPREFIX (buf, "Iface")) ++ goto out; ++ ++ /* First line is just headings, skip it */ ++ cur = strchr(buf, '\n'); ++ if (cur) ++ cur++; ++ ++ while (cur) { ++ char iface[17], dest[128], mask[128]; ++ unsigned int addr_val, mask_val; ++ int num; ++ ++ /* NUL-terminate the line, so sscanf doesn't go beyond a newline. */ ++ char *nl = strchr(cur, '\n'); ++ if (nl) { ++ *nl++ = '\0'; ++ } ++ ++ num = sscanf(cur, "%16s %127s %*s %*s %*s %*s %*s %127s", ++ iface, dest, mask); ++ cur = nl; ++ ++ if (num != 3) { ++ VIR_DEBUG("Failed to parse %s", PROC_NET_ROUTE); ++ continue; ++ } ++ ++ if (virStrToLong_ui(dest, NULL, 16, &addr_val) < 0) { ++ VIR_DEBUG("Failed to convert network address %s to uint", dest); ++ continue; ++ } ++ ++ if (virStrToLong_ui(mask, NULL, 16, &mask_val) < 0) { ++ VIR_DEBUG("Failed to convert network mask %s to uint", mask); ++ continue; ++ } ++ ++ addr_val &= mask_val; ++ ++ if ((net_dest == addr_val) && ++ (innetmask.inet4.sin_addr.s_addr == mask_val)) { ++ networkReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Network %s/%s is already in use by " ++ "interface %s"), ++ network->def->ipAddress, ++ network->def->netmask, iface); ++ goto error; ++ } ++ } ++ ++out: ++ ret = 0; ++error: ++ VIR_FREE(buf); ++ return ret; ++} ++ + static int networkStartNetworkDaemon(struct network_driver *driver, + virNetworkObjPtr network) + { +@@ -919,6 +1028,10 @@ static int networkStartNetworkDaemon(struct network_driver *driver, + return -1; + } + ++ /* Check to see if network collides with an existing route */ ++ if (networkCheckRouteCollision(network) < 0) ++ return -1; ++ + if ((err = brAddBridge(driver->brctl, network->def->bridge))) { + virReportSystemError(err, + _("cannot create bridge '%s'"), diff --git a/libvirt-0.7.7-sanitize-pool.patch b/libvirt-0.7.7-sanitize-pool.patch new file mode 100644 index 0000000..ad37b2c --- /dev/null +++ b/libvirt-0.7.7-sanitize-pool.patch @@ -0,0 +1,155 @@ +diff -rup libvirt-0.7.7/src/conf/storage_conf.c new/src/conf/storage_conf.c +--- libvirt-0.7.7/src/conf/storage_conf.c 2010-03-05 09:46:29.000000000 -0500 ++++ new/src/conf/storage_conf.c 2010-06-17 12:28:44.319588000 -0400 +@@ -601,6 +601,7 @@ virStoragePoolDefParseXML(xmlXPathContex + xmlNodePtr source_node; + char *type = NULL; + char *uuid = NULL; ++ char *tmppath; + + if (VIR_ALLOC(ret) < 0) { + virReportOOMError(); +@@ -698,11 +699,16 @@ virStoragePoolDefParseXML(xmlXPathContex + } + } + +- if ((ret->target.path = virXPathString("string(./target/path)", ctxt)) == NULL) { ++ if ((tmppath = virXPathString("string(./target/path)", ctxt)) == NULL) { + virStorageReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool target path")); + goto cleanup; + } ++ ret->target.path = virFileSanitizePath(tmppath); ++ VIR_FREE(tmppath); ++ if (!ret->target.path) ++ goto cleanup; ++ + + if (virStorageDefParsePerms(ctxt, &ret->target.perms, + "./target/permissions", 0700) < 0) +diff -rup libvirt-0.7.7/src/libvirt_private.syms new/src/libvirt_private.syms +--- libvirt-0.7.7/src/libvirt_private.syms 2010-03-05 10:45:23.000000000 -0500 ++++ new/src/libvirt_private.syms 2010-06-17 12:28:44.334585000 -0400 +@@ -582,6 +582,7 @@ virFileReadLimFD; + virFilePid; + virFileReadPid; + virFileLinkPointsTo; ++virFileSanitizePath; + virParseNumber; + virAsprintf; + virRun; +diff -rup libvirt-0.7.7/src/storage/storage_driver.c new/src/storage/storage_driver.c +--- libvirt-0.7.7/src/storage/storage_driver.c 2010-03-05 09:46:29.000000000 -0500 ++++ new/src/storage/storage_driver.c 2010-06-17 12:28:44.346586000 -0400 +@@ -1200,6 +1200,11 @@ storageVolumeLookupByPath(virConnectPtr + virStorageDriverStatePtr driver = conn->storagePrivateData; + unsigned int i; + virStorageVolPtr ret = NULL; ++ char *cleanpath; ++ ++ cleanpath = virFileSanitizePath(path); ++ if (!cleanpath) ++ return NULL; + + storageDriverLock(driver); + for (i = 0 ; i < driver->pools.count && !ret ; i++) { +@@ -1209,7 +1214,7 @@ storageVolumeLookupByPath(virConnectPtr + const char *stable_path; + + stable_path = virStorageBackendStablePath(driver->pools.objs[i], +- path); ++ cleanpath); + /* + * virStorageBackendStablePath already does + * virStorageReportError if it fails; we just need to keep +@@ -1238,6 +1243,7 @@ storageVolumeLookupByPath(virConnectPtr + "%s", _("no storage vol with matching path")); + + cleanup: ++ VIR_FREE(cleanpath); + storageDriverUnlock(driver); + return ret; + } +diff -rup libvirt-0.7.7/src/util/util.c new/src/util/util.c +--- libvirt-0.7.7/src/util/util.c 2010-03-03 05:48:25.000000000 -0500 ++++ new/src/util/util.c 2010-06-17 12:28:44.357588000 -0400 +@@ -1867,6 +1867,55 @@ int virFileAbsPath(const char *path, cha + return 0; + } + ++/* Remove spurious / characters from a path. The result must be freed */ ++char * ++virFileSanitizePath(const char *path) ++{ ++ const char *cur = path; ++ char *cleanpath; ++ int idx = 0; ++ ++ cleanpath = strdup(path); ++ if (!cleanpath) { ++ virReportOOMError(); ++ return NULL; ++ } ++ ++ /* Need to sanitize: ++ * // -> // ++ * /// -> / ++ * /../foo -> /../foo ++ * /foo///bar/ -> /foo/bar ++ */ ++ ++ /* Starting with // is valid posix, but ///foo == /foo */ ++ if (cur[0] == '/' && cur[1] == '/' && cur[2] != '/') { ++ idx = 2; ++ cur += 2; ++ } ++ ++ /* Sanitize path in place */ ++ while (*cur != '\0') { ++ if (*cur != '/') { ++ cleanpath[idx++] = *cur++; ++ continue; ++ } ++ ++ /* Skip all extra / */ ++ while (*++cur == '/') ++ continue; ++ ++ /* Don't add a trailing / */ ++ if (idx != 0 && *cur == '\0') ++ break; ++ ++ cleanpath[idx++] = '/'; ++ } ++ cleanpath[idx] = '\0'; ++ ++ return cleanpath; ++} ++ + /* Like strtol, but produce an "int" result, and check more carefully. + Return 0 upon success; return -1 to indicate failure. + When END_PTR is NULL, the byte after the final valid digit must be NUL. +diff -rup libvirt-0.7.7/src/util/util.h new/src/util/util.h +--- libvirt-0.7.7/src/util/util.h 2010-02-19 12:14:07.000000000 -0500 ++++ new/src/util/util.h 2010-06-17 12:28:44.364585000 -0400 +@@ -109,6 +109,8 @@ char *virFindFileInPath(const char *file + + int virFileExists(const char *path); + ++char *virFileSanitizePath(const char *path); ++ + enum { + VIR_FILE_OP_NONE = 0, + VIR_FILE_OP_AS_UID = (1 << 0), +diff -rup libvirt-0.7.7/tests/storagepoolxml2xmlin/pool-dir.xml new/tests/storagepoolxml2xmlin/pool-dir.xml +--- libvirt-0.7.7/tests/storagepoolxml2xmlin/pool-dir.xml 2009-12-22 04:37:57.000000000 -0500 ++++ new/tests/storagepoolxml2xmlin/pool-dir.xml 2010-06-17 12:28:44.367585000 -0400 +@@ -7,7 +7,7 @@ + + + +- /var/lib/libvirt/images ++ ///var/////lib/libvirt/images// + + 0700 + 0 diff --git a/libvirt-0.7.7-udev-wireless.patch b/libvirt-0.7.7-udev-wireless.patch new file mode 100644 index 0000000..41913d1 --- /dev/null +++ b/libvirt-0.7.7-udev-wireless.patch @@ -0,0 +1,66 @@ +commit 07f6c3a95f1caca368c8723b5b0a25ae2faa1ffe +Author: David Allan +Date: Thu May 27 10:44:02 2010 -0400 + + v2 of Cole's wlan support + + * Incorporated Jim's feedback (v1 & v2) + + * Moved case of DEVTYPE == "wlan" up as it's definitive that we have a network interface. + + * Made comment more detailed about the wired case to explain better + how it differentiates between wired network interfaces and USB + devices. + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index f0485f1..c437861 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -597,8 +597,15 @@ static int udevProcessNetworkInterface(struct udev_device *device, + virNodeDeviceDefPtr def) + { + int ret = -1; ++ const char *devtype = udev_device_get_devtype(device); + union _virNodeDevCapData *data = &def->caps->data; + ++ if (devtype && STREQ(devtype, "wlan")) { ++ data->net.subtype = VIR_NODE_DEV_CAP_NET_80211; ++ } else { ++ data->net.subtype = VIR_NODE_DEV_CAP_NET_80203; ++ } ++ + if (udevGetStringProperty(device, + "INTERFACE", + &data->net.ifname) == PROPERTY_ERROR) { +@@ -1074,6 +1081,8 @@ static int udevGetDeviceType(struct udev_device *device, + int ret = 0; + + devtype = udev_device_get_devtype(device); ++ VIR_DEBUG("Found device type '%s' for device '%s'", ++ NULLSTR(devtype), udev_device_get_sysname(device)); + + if (devtype != NULL && STREQ(devtype, "usb_device")) { + *type = VIR_NODE_DEV_CAP_USB_DEV; +@@ -1105,13 +1114,20 @@ static int udevGetDeviceType(struct udev_device *device, + goto out; + } + ++ if (devtype != NULL && STREQ(devtype, "wlan")) { ++ *type = VIR_NODE_DEV_CAP_NET; ++ goto out; ++ } ++ + if (udevGetUintProperty(device, "PCI_CLASS", &tmp, 16) == PROPERTY_FOUND) { + *type = VIR_NODE_DEV_CAP_PCI_DEV; + goto out; + } + +- /* It does not appear that network interfaces set the device type +- * property. */ ++ /* It does not appear that wired network interfaces set the ++ * DEVTYPE property. USB devices also have an INTERFACE property, ++ * but they do set DEVTYPE, so if devtype is NULL and the ++ * INTERFACE property exists, we have a network device. */ + if (devtype == NULL && + udevGetStringProperty(device, + "INTERFACE", diff --git a/libvirt.spec b/libvirt.spec index a2f8844..af5220f 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -169,7 +169,7 @@ Summary: Library providing a simple API virtualization Name: libvirt Version: 0.7.7 -Release: 4%{?dist}%{?extra_release} +Release: 5%{?dist}%{?extra_release} License: LGPLv2+ Group: Development/Libraries Source: http://libvirt.org/sources/libvirt-%{version}.tar.gz @@ -189,6 +189,22 @@ Patch6: %{name}-%{version}-fix-cdrom-change.patch Patch7: %{name}-%{version}-qemu-startup-output.patch # Fix crash from 'virsh dominfo' if secdriver disabled (bz 581166) Patch8: %{name}-%{version}-no-secdriver-crash.patch +# Add qemu.conf options for audio workaround +Patch9: %{name}-%{version}-audio-config.patch +# Fix parsing certain USB sysfs files (bz 598272) +Patch10: %{name}-%{version}-fix-usb-parsing.patch +# Sanitize pool target paths (bz 494005) +Patch11: %{name}-%{version}-sanitize-pool.patch +# Add qemu.conf for clear emulator capabilities +Patch12: %{name}-%{version}-caps-option.patch +# Prevent libvirtd inside a VM from breaking network access (bz 235961) +Patch13: %{name}-%{version}-network-collision.patch +# Mention --all in 'virsh list' docs (bz 575512) +Patch14: %{name}-%{version}-man-page-list.patch +# Initscript fixes (bz 565238) +Patch15: %{name}-%{version}-init-fixes.patch +# List wireless interfaces via nodedev-list (bz 596928) +Patch16: %{name}-%{version}-udev-wireless.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root URL: http://libvirt.org/ BuildRequires: python-devel @@ -418,6 +434,14 @@ of recent versions of Linux (and other OSes). %patch6 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 %build %if ! %{with_xen} @@ -839,6 +863,16 @@ fi %endif %changelog +* Thu Jun 17 2010 Cole Robinson - 0.7.7-5.fc13 +- Add qemu.conf options for audio workaround +- Fix parsing certain USB sysfs files (bz 598272) +- Sanitize pool target paths (bz 494005) +- Add qemu.conf for clear emulator capabilities +- Prevent libvirtd inside a VM from breaking network access (bz 235961) +- Mention --all in 'virsh list' docs (bz 575512) +- Initscript fixes (bz 565238) +- List wireless interfaces via nodedev-list (bz 596928) + * Tue May 18 2010 Cole Robinson - 0.7.7-4.fc13 - Fix nodedev XML conversion errors (bz 591262) - Fix PCI xml decimal parsing (bz 582752)