[libvirt] [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. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- 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 26b5600..0fa9b2f 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; } + DEBUG0("Preparing host devices"); + /* Must be run before security labelling */ + if (qemuPrepareHostDevices(driver, vm->def) < 0) + goto cleanup; + DEBUG0("Generating domain security label (if required)"); /* If you are using a SecurityDriver with dynamic labelling, then generate a security label for isolation */ @@ -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

On 03/12/2010 10:49 AM, Cole Robinson wrote:
We need to call PrepareHostdevs to determine the USB device path before any security calls. PrepareHostUSBDevices was also incorrectly skipping all USB devices.
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Le vendredi 12 mars 2010 à 18:49, Cole Robinson a écrit :
We need to call PrepareHostdevs to determine the USB device path before any security calls. PrepareHostUSBDevices was also incorrectly skipping all USB devices.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- 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 26b5600..0fa9b2f 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; }
+ DEBUG0("Preparing host devices"); + /* Must be run before security labelling */ + if (qemuPrepareHostDevices(driver, vm->def) < 0) + goto cleanup; + DEBUG0("Generating domain security label (if required)"); /* If you are using a SecurityDriver with dynamic labelling, then generate a security label for isolation */ @@ -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;
I confirm that patch solves the following problem : https://www.redhat.com/archives/libvir-list/2010-March/msg00319.html -- Laurent Léonard

On 03/12/2010 12:49 PM, Cole Robinson wrote:
We need to call PrepareHostdevs to determine the USB device path before any security calls. PrepareHostUSBDevices was also incorrectly skipping all USB devices.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_driver.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
Pushed now (along with the StartupVMDaemon debugging changes). - Cole
participants (3)
-
Cole Robinson
-
Eric Blake
-
Laurent Léonard