Compare commits

...

9 Commits

Author SHA1 Message Date
Cole Robinson 3d90c2f845 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)
2010-06-17 17:42:36 +00:00
Cole Robinson 5c3e8a7ac0 Fix nodedev XML conversion errors (bz 591262)
Fix PCI xml decimal parsing (bz 582752)
Fix CDROM media connect/eject (bz 582005)
Always report qemu startup output on error (bz 581381)
Fix crash from 'virsh dominfo' if secdriver disabled (bz 581166)
2010-05-18 18:49:49 +00:00
Cole Robinson 09a86187e8 Fix slow storage volume allocation (bz 582356) 2010-04-20 19:39:41 +00:00
Cole Robinson a8bac7d647 Fix USB devices by product with security enabled (bz 574136)
Set kernel/initrd in security driver, fixes some URL installs (bz 566425)
2010-03-22 15:09:54 +00:00
Daniel Veillard 74d9fb3860 oops forgot to update sources too, Daniel 2010-03-05 17:11:45 +00:00
Daniel Veillard 1b3b9bf1cc Upstream release of 0.7.7,
Daniel
2010-03-05 16:59:20 +00:00
Adam Jackson 1d1a47ccaf bump to appease cvs 2010-02-17 15:34:59 +00:00
Adam Jackson 14f81abaae all of libvirt_test.la needs -ldl 2010-02-17 15:33:23 +00:00
Jesse Keating 6b3af81b0e Initialize branch F-13 for libvirt 2010-02-17 01:56:25 +00:00
20 changed files with 1613 additions and 22 deletions

1
branch Normal file
View File

@ -0,0 +1 @@
F-13

View File

@ -1,12 +0,0 @@
diff -up libvirt-0.7.6/tests/Makefile.am.jx libvirt-0.7.6/tests/Makefile.am
--- libvirt-0.7.6/tests/Makefile.am.jx 2010-01-21 09:32:37.000000000 -0500
+++ libvirt-0.7.6/tests/Makefile.am 2010-02-16 18:49:36.000000000 -0500
@@ -317,7 +317,7 @@ conftest_LDADD = $(LDADDS)
nodeinfotest_SOURCES = \
nodeinfotest.c testutils.h testutils.c
-nodeinfotest_LDADD = $(LDADDS)
+nodeinfotest_LDADD = $(LDADDS) -ldl
statstest_SOURCES = \
statstest.c testutils.h testutils.c

View File

@ -0,0 +1,163 @@
commit 377bc412ce10845930346744e30fe9c4790e5e63
Author: Cole Robinson <crobinso@redhat.com>
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 <crobinso@redhat.com>
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 <crobinso@redhat.com>
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" }

View File

@ -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" }

View File

@ -0,0 +1,132 @@
commit c4896d378b921ba6471562d7b17641be121c19d6
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Thu Apr 15 11:35:07 2010 +0100
Fix CDROM media change for QEMU when using -device syntax
Disk devices in QEMU have two parts, the guest device and the host
backend driver. Historically these two parts have had the same
"unique" name. With the switch to using -device though, they now
have separate names. Thus when changing CDROM media, for guests
using -device syntax, we need to prepend the QEMU_DRIVE_HOST_PREFIX
constant
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Add helper function
qemuDeviceDriveHostAlias() for building a host backend alias
* src/qemu/qemu_driver.c: Use qemuDeviceDriveHostAlias() to determine
the host backend alias for performing eject/change commands in the
monitor
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1a8b4aa..0cbedf2 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1699,6 +1699,26 @@ static int qemuAssignDeviceDiskAliasLegacy(virDomainDiskDefPtr disk)
}
+char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
+ unsigned long long qemudCmdFlags)
+{
+ char *ret;
+
+ if (qemudCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ if (virAsprintf(&ret, "%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+ } else {
+ if (!(ret = strdup(disk->info.alias))) {
+ virReportOOMError();
+ return NULL;
+ }
+ }
+ return ret;
+}
+
+
/* Names used before -drive supported the id= option */
static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk)
{
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 574709e..b2820f0 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -220,6 +220,9 @@ char * qemuBuildNicStr(virDomainNetDefPtr net,
char * qemuBuildNicDevStr(virDomainNetDefPtr net,
int vlan);
+char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
+ unsigned long long qemudCmdFlags);
+
/* Both legacy & current support */
char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
int bootable,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0189dcf..7d2f3ef 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6552,11 +6552,13 @@ cleanup:
static int qemudDomainChangeEjectableMedia(struct qemud_driver *driver,
virDomainObjPtr vm,
- virDomainDiskDefPtr disk)
+ virDomainDiskDefPtr disk,
+ unsigned long long qemuCmdFlags)
{
virDomainDiskDefPtr origdisk = NULL;
int i;
int ret;
+ char *driveAlias = NULL;
origdisk = NULL;
for (i = 0 ; i < vm->def->ndisks ; i++) {
@@ -6594,6 +6596,9 @@ static int qemudDomainChangeEjectableMedia(struct qemud_driver *driver,
driver->securityDriver->domainSetSecurityImageLabel(vm, disk) < 0)
return -1;
+ if (!(driveAlias = qemuDeviceDriveHostAlias(origdisk, qemuCmdFlags)))
+ goto error;
+
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (disk->src) {
@@ -6605,10 +6610,10 @@ static int qemudDomainChangeEjectableMedia(struct qemud_driver *driver,
format = origdisk->driverType;
}
ret = qemuMonitorChangeMedia(priv->mon,
- origdisk->info.alias,
+ driveAlias,
disk->src, format);
} else {
- ret = qemuMonitorEjectMedia(priv->mon, origdisk->info.alias);
+ ret = qemuMonitorEjectMedia(priv->mon, driveAlias);
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -6625,11 +6630,14 @@ static int qemudDomainChangeEjectableMedia(struct qemud_driver *driver,
disk->src = NULL;
origdisk->type = disk->type;
+ VIR_FREE(driveAlias);
+
virDomainDiskDefFree(disk);
return ret;
error:
+ VIR_FREE(driveAlias);
if (driver->securityDriver &&
driver->securityDriver->domainRestoreSecurityImageLabel &&
driver->securityDriver->domainRestoreSecurityImageLabel(vm, disk) < 0)
@@ -7434,7 +7442,9 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
switch (dev->data.disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
- ret = qemudDomainChangeEjectableMedia(driver, vm, dev->data.disk);
+ ret = qemudDomainChangeEjectableMedia(driver, vm,
+ dev->data.disk,
+ qemuCmdFlags);
if (ret == 0)
dev->data.disk = NULL;
break;

View File

@ -0,0 +1,41 @@
From e3c36a2575bc88a16d776693dc39ea01c780b406 Mon Sep 17 00:00:00 2001
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 16 Mar 2010 16:03:59 +0100
Subject: [PATCH] Use fsync() at the end of file allocation instead of O_DSYNC
Instead of opening storage file with O_DSYNC, make sure data are written
to a disk only before we claim allocation has finished.
---
src/storage/storage_backend.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index ec9fc43..7294a00 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -331,6 +331,13 @@ static int createRawFileOpHook(int fd, void *data) {
goto cleanup;
}
}
+
+ if (fsync(fd) < 0) {
+ ret = errno;
+ virReportSystemError(errno, _("cannot sync data to file '%s'"),
+ hdata->vol->target.path);
+ goto cleanup;
+ }
}
cleanup:
@@ -359,7 +366,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
gid_t gid = (vol->target.perms.gid == -1) ? getgid() : vol->target.perms.gid;
if ((createstat = virFileOperation(vol->target.path,
- O_RDWR | O_CREAT | O_EXCL | O_DSYNC,
+ O_RDWR | O_CREAT | O_EXCL,
vol->target.perms.mode, uid, gid,
createRawFileOpHook, &hdata,
VIR_FILE_OP_FORCE_PERMS |
--
1.6.6.1

View File

@ -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) {

View File

@ -0,0 +1,233 @@
From 3a441522017aa9c1b8b54d2ce4569d0f0d96fa72 Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Fri, 12 Mar 2010 12:36:56 -0500
Subject: [PATCH] qemu: Add some debugging at domain startup
---
src/qemu/qemu_driver.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f8ab545..040d645 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2695,6 +2695,8 @@ static int qemudStartVMDaemon(virConnectPtr conn,
FD_ZERO(&keepfd);
+ DEBUG0("Beginning VM startup process");
+
if (virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("VM is already active"));
@@ -2703,22 +2705,27 @@ static int qemudStartVMDaemon(virConnectPtr conn,
/* If you are using a SecurityDriver with dynamic labelling,
then generate a security label for isolation */
+ DEBUG0("Generating domain security label (if required)");
if (driver->securityDriver &&
driver->securityDriver->domainGenSecurityLabel &&
driver->securityDriver->domainGenSecurityLabel(vm) < 0)
return -1;
+ DEBUG0("Generating setting domain security labels (if required)");
if (driver->securityDriver &&
driver->securityDriver->domainSetSecurityAllLabel &&
driver->securityDriver->domainSetSecurityAllLabel(vm) < 0)
goto cleanup;
- /* Ensure no historical cgroup for this VM is lieing around bogus settings */
+ /* Ensure no historical cgroup for this VM is lying around bogus
+ * settings */
+ DEBUG0("Ensuring no historical cgroup is lying around");
qemuRemoveCgroup(driver, vm, 1);
if ((vm->def->ngraphics == 1) &&
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
vm->def->graphics[0]->data.vnc.autoport) {
+ DEBUG0("Determining VNC port");
int port = qemudNextFreeVNCPort(driver);
if (port < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2735,6 +2742,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
goto cleanup;
}
+ DEBUG0("Creating domain log file");
if ((logfile = qemudLogFD(driver, vm->def->name)) < 0)
goto cleanup;
@@ -2751,14 +2759,17 @@ static int qemudStartVMDaemon(virConnectPtr conn,
goto cleanup;
}
+ DEBUG0("Determing emulator version");
if (qemudExtractVersionInfo(emulator,
NULL,
&qemuCmdFlags) < 0)
goto cleanup;
+ DEBUG0("Setting up domain cgroup (if required)");
if (qemuSetupCgroup(driver, vm) < 0)
goto cleanup;
+ DEBUG0("Preparing host devices");
if (qemuPrepareHostDevices(driver, vm->def) < 0)
goto cleanup;
@@ -2767,6 +2778,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
goto cleanup;
}
+ DEBUG0("Preparing monitor state");
if (qemuPrepareMonitorChr(driver, priv->monConfig, vm->def->name) < 0)
goto cleanup;
@@ -2798,6 +2810,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
* use in hotplug
*/
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ DEBUG0("Assigning domain PCI addresses");
/* Populate cache with current addresses */
if (priv->pciaddrs) {
qemuDomainPCIAddressSetFree(priv->pciaddrs);
@@ -2816,6 +2829,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
priv->persistentAddrs = 0;
}
+ DEBUG0("Building emulator command line");
vm->def->id = driver->nextvmid++;
if (qemudBuildCommandLine(conn, driver, vm->def, priv->monConfig,
priv->monJSON, qemuCmdFlags, &argv, &progenv,
@@ -2899,25 +2913,31 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if (ret == -1) /* The VM failed to start */
goto cleanup;
+ DEBUG0("Waiting for monitor to show up");
if (qemudWaitForMonitor(driver, vm, pos) < 0)
goto abort;
+ DEBUG0("Detecting VCPU PIDs");
if (qemuDetectVcpuPIDs(driver, vm) < 0)
goto abort;
+ DEBUG0("Setting CPU affinity");
if (qemudInitCpuAffinity(vm) < 0)
goto abort;
+ DEBUG0("Setting any required VM passwords");
if (qemuInitPasswords(conn, driver, vm, qemuCmdFlags) < 0)
goto abort;
/* If we have -device, then addresses are assigned explicitly.
* If not, then we have to detect dynamic ones here */
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+ DEBUG0("Determining domain device PCI addresses");
if (qemuInitPCIAddresses(driver, vm) < 0)
goto abort;
}
+ DEBUG0("Setting initial memory amount");
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorSetBalloon(priv->mon, vm->def->memory) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -2925,6 +2945,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
}
if (migrateFrom == NULL) {
+ DEBUG0("Starting domain CPUs");
/* Allow the CPUS to start executing */
if (qemuMonitorStartCPUs(priv->mon, conn) < 0) {
if (virGetLastError() == NULL)
@@ -2937,6 +2958,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
qemuDomainObjExitMonitorWithDriver(driver, vm);
+ DEBUG0("Writing domain status to disk");
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
goto abort;
--
1.6.6.1
From 6d5c8a8f51db8ce97ab35ab6022dd5c94ab016b4 Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Fri, 12 Mar 2010 12:37:52 -0500
Subject: [PATCH] qemu: Fix USB by product with security enabled
We need to call PrepareHostdevs to determine the USB device path before
any security calls. PrepareHostUSBDevices was also incorrectly skipping
all USB devices.
---
src/qemu/qemu_driver.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 040d645..b17d26d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2360,7 +2360,7 @@ qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
continue;
- if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+ if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
continue;
/* Resolve a vendor/product to bus/device */
@@ -2703,6 +2703,11 @@ static int qemudStartVMDaemon(virConnectPtr conn,
return -1;
}
+ /* Must be run before security labelling */
+ DEBUG0("Preparing host devices");
+ if (qemuPrepareHostDevices(driver, vm->def) < 0)
+ goto cleanup;
+
/* If you are using a SecurityDriver with dynamic labelling,
then generate a security label for isolation */
DEBUG0("Generating domain security label (if required)");
@@ -2769,10 +2774,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if (qemuSetupCgroup(driver, vm) < 0)
goto cleanup;
- DEBUG0("Preparing host devices");
- if (qemuPrepareHostDevices(driver, vm->def) < 0)
- goto cleanup;
-
if (VIR_ALLOC(priv->monConfig) < 0) {
virReportOOMError();
goto cleanup;
--
1.6.6.1
From 65e97240e6e4606820dd1c42ac172319e0af4d8d Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Mon, 22 Mar 2010 10:45:36 -0400
Subject: [PATCH] security: selinux: Fix crash when releasing non-existent label
This can be triggered by the qemuStartVMDaemon cleanup path if a
VM references a non-existent USB device (by product) in the XML.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
src/security/security_selinux.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 975b315..6680e2d 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -632,7 +632,8 @@ SELinuxReleaseSecurityLabel(virDomainObjPtr vm)
{
const virSecurityLabelDefPtr secdef = &vm->def->seclabel;
- if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC)
+ if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC ||
+ secdef->label == NULL)
return 0;
context_t con = context_new(secdef->label);
--
1.6.6.1

View File

@ -0,0 +1,35 @@
commit 9d0adf249827dde9e1c0d1c19513cf6018ceb34e
Author: Cole Robinson <crobinso@redhat.com>
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

View File

@ -0,0 +1,65 @@
commit e5f31f461f63bbad211e84b810d6ba43a705f9dd
Author: Justin Clift <justin@salasaga.org>
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<http://libvirt.org/formatcaps.html>
The XML also show the NUMA topology information if available.
-=item B<list>
+=item B<list> 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<STATES>
-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<shut off>
+
+The domain is not running. Usually this indicates the domain has been
+shut down completely, or has not been started.
+
=item B<crashed>
The domain has crashed, which is always a violent ending. Usually

View File

@ -0,0 +1,169 @@
commit a83fe2c23efad190a1e00e448f607fe032650fd6
Author: Cole Robinson <crobinso@redhat.com>
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'"),

View File

@ -0,0 +1,26 @@
commit b7a7b3365145f6e9e434a3265a58666cd2e6d8dd
Author: Guido Günther <agx@sigxcpu.org>
Date: Wed Mar 17 21:04:11 2010 +0100
Don't crash without a security driver
"virsh dominfo <vm>" crashes if there's no primary security driver set
since we only intialize the secmodel.model and secmodel.doi if we have
one. Attached patch checks for securityPrimaryDriver instead of
securityDriver since the later is always set in qemudSecurityInit().
Closes: http://bugs.debian.org/574359
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1f2b11d..257f914 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4979,7 +4979,7 @@ static int qemudNodeGetSecurityModel(virConnectPtr conn,
int ret = 0;
qemuDriverLock(driver);
- if (!driver->securityDriver) {
+ if (!driver->securityPrimaryDriver) {
memset(secmodel, 0, sizeof (*secmodel));
goto cleanup;
}

View File

@ -0,0 +1,77 @@
commit 74c7a3463d18a530d6d749d0199061b5d3f17faa
Author: Cole Robinson <crobinso@redhat.com>
Date: Tue May 11 14:44:34 2010 -0400
node_device: udev: Fix PCI product/vendor swappage
Product and vendor values were swapped in the XML, which made virt-manager
PCI device listing kinda useless.
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index bcfe991..4a9d65f 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -382,8 +382,8 @@ static int udevTranslatePCIIds(unsigned int vendor,
/* pci_get_strings returns void */
pci_get_strings(&m,
- &vendor_name,
&device_name,
+ &vendor_name,
NULL,
NULL);
commit 75d88455f54088f88bc7a503da0a4cd413ef7b95
Author: Klaus Ethgen <Klaus@Ethgen.de>
Date: Tue Apr 27 09:20:47 2010 +0200
The base used for conversion of USB values should be 16 not 10.
Signed-off-by: Guido Günther <agx@sigxcpu.org>
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index b12a49e..3a5a7e2 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -548,8 +548,6 @@ out:
}
-/* XXX Is 10 the correct base for the Number/Class/SubClass/Protocol
- * conversions? */
static int udevProcessUSBInterface(struct udev_device *device,
virNodeDeviceDefPtr def)
{
@@ -559,28 +557,28 @@ static int udevProcessUSBInterface(struct udev_device *device,
if (udevGetUintSysfsAttr(device,
"bInterfaceNumber",
&data->usb_if.number,
- 10) == PROPERTY_ERROR) {
+ 16) == PROPERTY_ERROR) {
goto out;
}
if (udevGetUintSysfsAttr(device,
"bInterfaceClass",
&data->usb_if._class,
- 10) == PROPERTY_ERROR) {
+ 16) == PROPERTY_ERROR) {
goto out;
}
if (udevGetUintSysfsAttr(device,
"bInterfaceSubClass",
&data->usb_if.subclass,
- 10) == PROPERTY_ERROR) {
+ 16) == PROPERTY_ERROR) {
goto out;
}
if (udevGetUintSysfsAttr(device,
"bInterfaceProtocol",
&data->usb_if.protocol,
- 10) == PROPERTY_ERROR) {
+ 16) == PROPERTY_ERROR) {
goto out;
}

View File

@ -0,0 +1,50 @@
commit e984019688509605966c03cd77f4591d2cc222d3
Author: Cole Robinson <crobinso@redhat.com>
Date: Fri Apr 30 18:14:35 2010 +0200
domain: Fix PCI address decimal parsing regression
<hostdev> address parsing previously attempted to detect the number
base: currently it is hardcoded to base 16, which can break PCI
assignment via virt-manager. Revert to the previous behavior.
* src/conf/domain_conf.c: virDomainDevicePCIAddressParseXML, switch to
virStrToLong_ui(bus, NULL, 0, ...) to autodetect base
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1607e8b..546ddf2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1079,28 +1079,28 @@ virDomainDevicePCIAddressParseXML(xmlNodePtr node,
function = virXMLPropString(node, "function");
if (domain &&
- virStrToLong_ui(domain, NULL, 16, &addr->domain) < 0) {
+ virStrToLong_ui(domain, NULL, 0, &addr->domain) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot parse <address> 'domain' attribute"));
goto cleanup;
}
if (bus &&
- virStrToLong_ui(bus, NULL, 16, &addr->bus) < 0) {
+ virStrToLong_ui(bus, NULL, 0, &addr->bus) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot parse <address> 'bus' attribute"));
goto cleanup;
}
if (slot &&
- virStrToLong_ui(slot, NULL, 16, &addr->slot) < 0) {
+ virStrToLong_ui(slot, NULL, 0, &addr->slot) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot parse <address> 'slot' attribute"));
goto cleanup;
}
if (function &&
- virStrToLong_ui(function, NULL, 16, &addr->function) < 0) {
+ virStrToLong_ui(function, NULL, 0, &addr->function) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot parse <address> 'function' attribute"));
goto cleanup;

View File

@ -0,0 +1,108 @@
commit 83be64034a0b530c904ceb4fd1ed1c10b5cdf4bf
Author: Cole Robinson <crobinso@redhat.com>
Date: Mon May 17 10:15:53 2010 -0400
qemu: Report cmdline output if VM dies early
qemuReadLogOutput early VM death detection is racy and won't always work.
Startup then errors when connecting to the VM monitor. This won't report
the emulator cmdline output which is typically the most useful diagnostic.
Check if the VM has died at the very end of the monitor connection step,
and if so, report the cmdline output.
See also: https://bugzilla.redhat.com/show_bug.cgi?id=581381
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ab6bec8..582fdee 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2034,39 +2034,47 @@ static void qemudFreePtyPath(void *payload, const char *name ATTRIBUTE_UNUSED)
VIR_FREE(payload);
}
+static void
+qemuReadLogFD(int logfd, char *buf, int maxlen, int off)
+{
+ int ret;
+ char *tmpbuf = buf + off;
+
+ ret = saferead(logfd, tmpbuf, maxlen - off - 1);
+ if (ret < 0) {
+ ret = 0;
+ }
+
+ tmpbuf[ret] = '\0';
+}
+
static int
qemudWaitForMonitor(struct qemud_driver* driver,
virDomainObjPtr vm, off_t pos)
{
- char buf[4096]; /* Plenty of space to get startup greeting */
+ char buf[4096] = ""; /* Plenty of space to get startup greeting */
int logfd;
int ret = -1;
+ virHashTablePtr paths = NULL;
- if ((logfd = qemudLogReadFD(driver->logDir, vm->def->name, pos))
- < 0)
+ if ((logfd = qemudLogReadFD(driver->logDir, vm->def->name, pos)) < 0)
return -1;
- ret = qemudReadLogOutput(vm, logfd, buf, sizeof(buf),
- qemudFindCharDevicePTYs,
- "console", 30);
- if (close(logfd) < 0) {
- char ebuf[4096];
- VIR_WARN(_("Unable to close logfile: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
- }
-
- if (ret < 0)
- return -1;
+ if (qemudReadLogOutput(vm, logfd, buf, sizeof(buf),
+ qemudFindCharDevicePTYs,
+ "console", 30) < 0)
+ goto closelog;
VIR_DEBUG("Connect monitor to %p '%s'", vm, vm->def->name);
- if (qemuConnectMonitor(driver, vm) < 0)
- return -1;
+ if (qemuConnectMonitor(driver, vm) < 0) {
+ goto cleanup;
+ }
/* Try to get the pty path mappings again via the monitor. This is much more
* reliable if it's available.
* Note that the monitor itself can be on a pty, so we still need to try the
* log output method. */
- virHashTablePtr paths = virHashCreate(0);
+ paths = virHashCreate(0);
if (paths == NULL) {
virReportOOMError();
goto cleanup;
@@ -2087,6 +2095,23 @@ cleanup:
virHashFree(paths, qemudFreePtyPath);
}
+ if (kill(vm->pid, 0) == -1 && errno == ESRCH) {
+ /* VM is dead, any other error raised in the interim is probably
+ * not as important as the qemu cmdline output */
+ qemuReadLogFD(logfd, buf, sizeof(buf), strlen(buf));
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("process exited while connecting to monitor: %s"),
+ buf);
+ ret = -1;
+ }
+
+closelog:
+ if (close(logfd) < 0) {
+ char ebuf[4096];
+ VIR_WARN(_("Unable to close logfile: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
+ }
+
return ret;
}

View File

@ -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 @@
<source>
</source>
<target>
- <path>/var/lib/libvirt/images</path>
+ <path>///var/////lib/libvirt/images//</path>
<permissions>
<mode>0700</mode>
<owner>0</owner>

View File

@ -0,0 +1,87 @@
From 3f1aa08af6580c215d973bc6bf57f505dbf8b926 Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Fri, 12 Mar 2010 13:38:39 -0500
Subject: [PATCH] security: Set permissions for kernel/initrd
Fixes URL installs when running virt-install as root on Fedora.
---
src/qemu/qemu_security_dac.c | 21 +++++++++++++++++++++
src/security/security_selinux.c | 16 ++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c
index 6911f48..1883fbe 100644
--- a/src/qemu/qemu_security_dac.c
+++ b/src/qemu/qemu_security_dac.c
@@ -332,6 +332,15 @@ qemuSecurityDACRestoreSecurityAllLabel(virDomainObjPtr vm)
vm->def->disks[i]) < 0)
rc = -1;
}
+
+ if (vm->def->os.kernel &&
+ qemuSecurityDACRestoreSecurityFileLabel(vm->def->os.kernel) < 0)
+ rc = -1;
+
+ if (vm->def->os.initrd &&
+ qemuSecurityDACRestoreSecurityFileLabel(vm->def->os.initrd) < 0)
+ rc = -1;
+
return rc;
}
@@ -356,6 +365,18 @@ qemuSecurityDACSetSecurityAllLabel(virDomainObjPtr vm)
return -1;
}
+ if (vm->def->os.kernel &&
+ qemuSecurityDACSetOwnership(vm->def->os.kernel,
+ driver->user,
+ driver->group) < 0)
+ return -1;
+
+ if (vm->def->os.initrd &&
+ qemuSecurityDACSetOwnership(vm->def->os.initrd,
+ driver->user,
+ driver->group) < 0)
+ return -1;
+
return 0;
}
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index b2c8581..975b315 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -616,6 +616,14 @@ SELinuxRestoreSecurityAllLabel(virDomainObjPtr vm)
rc = -1;
}
+ if (vm->def->os.kernel &&
+ SELinuxRestoreSecurityFileLabel(vm->def->os.kernel) < 0)
+ rc = -1;
+
+ if (vm->def->os.initrd &&
+ SELinuxRestoreSecurityFileLabel(vm->def->os.initrd) < 0)
+ rc = -1;
+
return rc;
}
@@ -736,6 +744,14 @@ SELinuxSetSecurityAllLabel(virDomainObjPtr vm)
return -1;
}
+ if (vm->def->os.kernel &&
+ SELinuxSetFilecon(vm->def->os.kernel, default_content_context) < 0)
+ return -1;
+
+ if (vm->def->os.initrd &&
+ SELinuxSetFilecon(vm->def->os.initrd, default_content_context) < 0)
+ return -1;
+
return 0;
}
--
1.6.6.1

View File

@ -0,0 +1,66 @@
commit 07f6c3a95f1caca368c8723b5b0a25ae2faa1ffe
Author: David Allan <dallan@redhat.com>
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",

View File

@ -1,4 +1,3 @@
%define _default_patch_fuzz 2 \n\n
# -*- rpm-spec -*- # -*- rpm-spec -*-
# A client only build will create a libvirt.so only containing # A client only build will create a libvirt.so only containing
@ -169,11 +168,43 @@
Summary: Library providing a simple API virtualization Summary: Library providing a simple API virtualization
Name: libvirt Name: libvirt
Version: 0.7.6 Version: 0.7.7
Release: 2%{?dist}%{?extra_release} Release: 5%{?dist}%{?extra_release}
License: LGPLv2+ License: LGPLv2+
Group: Development/Libraries Group: Development/Libraries
Source: http://libvirt.org/sources/libvirt-%{version}.tar.gz Source: http://libvirt.org/sources/libvirt-%{version}.tar.gz
# Fix USB devices by product with security enabled (bz 574136)
Patch1: %{name}-%{version}-fix-usb-product.patch
# Set kernel/initrd in security driver, fixes some URL installs (bz 566425)
Patch2: %{name}-%{version}-set-kernel-perms.patch
# Fix slow storage volume allocation (bz 582356)
Patch3: %{name}-%{version}-fix-slow-dsync.patch
# Fix nodedev XML conversion errors (bz 591262)
Patch4: %{name}-%{version}-nodedev-conversions.patch
# Fix PCI xml decimal parsing (bz 582752)
Patch5: %{name}-%{version}-pci-decimal-parsing.patch
# Fix CDROM media connect/eject (bz 582005)
Patch6: %{name}-%{version}-fix-cdrom-change.patch
# Always report qemu startup output on error (bz 581381)
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 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/ URL: http://libvirt.org/
BuildRequires: python-devel BuildRequires: python-devel
@ -343,10 +374,6 @@ BuildRequires: netcf-devel >= 0.1.4
# Fedora build root suckage # Fedora build root suckage
BuildRequires: gawk BuildRequires: gawk
# --no-add-needed changes
BuildRequires: autoconf automake libtool
Patch0: libvirt-0.7.6-add-needed.patch
%description %description
Libvirt is a C toolkit to interact with the virtualization capabilities Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). The main package includes of recent versions of Linux (and other OSes). The main package includes
@ -399,7 +426,22 @@ of recent versions of Linux (and other OSes).
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .add-needed %patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%build %build
%if ! %{with_xen} %if ! %{with_xen}
@ -514,7 +556,6 @@ of recent versions of Linux (and other OSes).
%define _without_yajl --without-yajl %define _without_yajl --without-yajl
%endif %endif
autoreconf -v --install
%configure %{?_without_xen} \ %configure %{?_without_xen} \
%{?_without_qemu} \ %{?_without_qemu} \
%{?_without_openvz} \ %{?_without_openvz} \
@ -822,6 +863,38 @@ fi
%endif %endif
%changelog %changelog
* Thu Jun 17 2010 Cole Robinson <crobinso@redhat.com> - 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 <crobinso@redhat.com> - 0.7.7-4.fc13
- Fix nodedev XML conversion errors (bz 591262)
- Fix PCI xml decimal parsing (bz 582752)
- Fix CDROM media connect/eject (bz 582005)
- Always report qemu startup output on error (bz 581381)
- Fix crash from 'virsh dominfo' if secdriver disabled (bz 581166)
* Tue Apr 20 2010 Cole Robinson <crobinso@redhat.com> - 0.7.7-3.fc13
- Fix slow storage volume allocation (bz 582356)
* Mon Mar 22 2010 Cole Robinson <crobinso@redhat.com> - 0.7.7-2.fc13
- Fix USB devices by product with security enabled (bz 574136)
- Set kernel/initrd in security driver, fixes some URL installs (bz 566425)
* Fri Mar 5 2010 Daniel Veillard <veillard@redhat.com> - 0.7.7-1
- macvtap support
- async job handling
- virtio channel
- computing baseline CPU
- virDomain{Attach,Detach}DeviceFlags
- assorted bug fixes and lots of cleanups
* Tue Feb 16 2010 Adam Jackson <ajax@redhat.com> 0.7.6-2 * Tue Feb 16 2010 Adam Jackson <ajax@redhat.com> 0.7.6-2
- libvirt-0.7.6-add-needed.patch: Fix FTBFS from --no-add-needed - libvirt-0.7.6-add-needed.patch: Fix FTBFS from --no-add-needed
- Add BuildRequires: xmlrpc-c-client for libxmlrpc_client.so - Add BuildRequires: xmlrpc-c-client for libxmlrpc_client.so

View File

@ -1 +1 @@
eaf0cf593d82d2dec6dca96abe56744e libvirt-0.7.6.tar.gz 5f315b0bf20e3964f7657ba1e630cd67 libvirt-0.7.7.tar.gz