File c6f0e177-qusb-qemu-check.patch of Package libvirt

From c6f0e177a3b6873830ccaf87fc2732d5ef45b3ad Mon Sep 17 00:00:00 2001
From: Chunyan Liu <cyliu@suse.com>
Date: Wed, 15 Jun 2016 14:00:14 +0800
Subject: [PATCH 6/6] qemuDomainDeviceDefPostParse: add USB controller model
 check

To sync with virDomainControllerModelUSB, we add two models
in qemuControllerModelUSB 'qusb1' and 'qusb2', but those
models are not supported in qemu driver. So add check in
device post parse to report errors if 'qusb1' and 'qusb2'
are specified.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
---
 src/qemu/qemu_domain.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Index: libvirt-2.0.0/src/qemu/qemu_domain.c
===================================================================
--- libvirt-2.0.0.orig/src/qemu/qemu_domain.c
+++ libvirt-2.0.0/src/qemu/qemu_domain.c
@@ -2335,6 +2335,19 @@ qemuDomainDeviceDefPostParse(virDomainDe
         ARCH_IS_S390(def->os.arch))
         dev->data.controller->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
 
+    /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */
+    if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER &&
+        dev->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
+        (dev->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1 ||
+         dev->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("USB controller model type 'qusb1' or 'qusb2' "
+                         "is not supported in %s"),
+                       virDomainVirtTypeToString(def->virtType));
+        goto cleanup;
+    }
+
+
     /* set the default SCSI controller model for S390 arches */
     if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER &&
         dev->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&