File be146b34-extend-usb-controller-model.patch of Package libvirt

From be146b349f603cdf1d86701418fa111323c40f12 Mon Sep 17 00:00:00 2001
From: Chunyan Liu <cyliu@suse.com>
Date: Wed, 15 Jun 2016 14:00:08 +0800
Subject: [PATCH 1/6] extend usb controller model to support xen pvusb

According to libxl implementation, it supports pvusb
controller of version 1.1 and version 2.0, and it
supports two types of backend, 'pvusb' (dom0 backend)
and 'qusb' (qemu backend). But currently pvusb backend
is not checked in yet.

To match libxl support, extend usb controller schema
to support two more models: qusb1 (qusb, version 1.1)
and 'qusb2' (qusb version 2.0).

Signed-off-by: Chunyan Liu <cyliu@suse.com>
---
 docs/formatdomain.html.in     | 4 +++-
 docs/schemas/domaincommon.rng | 2 ++
 src/conf/domain_addr.c        | 6 ++++++
 src/conf/domain_conf.c        | 2 ++
 src/conf/domain_conf.h        | 2 ++
 src/qemu/qemu_command.c       | 2 ++
 6 files changed, 17 insertions(+), 1 deletion(-)

Index: libvirt-2.0.0/docs/formatdomain.html.in
===================================================================
--- libvirt-2.0.0.orig/docs/formatdomain.html.in
+++ libvirt-2.0.0/docs/formatdomain.html.in
@@ -3122,7 +3122,9 @@
         <dd>A <code>usb</code> controller has an optional attribute
         <code>model</code>, which is one of "piix3-uhci", "piix4-uhci",
         "ehci", "ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
-        "vt82c686b-uhci", "pci-ohci" or "nec-xhci".  Additionally,
+        "vt82c686b-uhci", "pci-ohci", "nec-xhci", "qusb1" (xen pvusb
+        with qemu backend, version 1.1) or "qusb2" (xen pvusb with qemu
+        backend, version 2.0). Additionally,
          <span class="since">since 0.10.0</span>, if the USB bus needs to
          be explicitly disabled for the guest, <code>model='none'</code>
          may be used.  <span class="since">Since 1.0.5</span>, no default
Index: libvirt-2.0.0/docs/schemas/domaincommon.rng
===================================================================
--- libvirt-2.0.0.orig/docs/schemas/domaincommon.rng
+++ libvirt-2.0.0/docs/schemas/domaincommon.rng
@@ -1782,6 +1782,8 @@
                   <value>pci-ohci</value>
                   <value>nec-xhci</value>
                   <value>none</value>
+                  <value>qusb1</value>
+                  <value>qusb2</value>
                 </choice>
               </attribute>
             </optional>
Index: libvirt-2.0.0/src/conf/domain_addr.c
===================================================================
--- libvirt-2.0.0.orig/src/conf/domain_addr.c
+++ libvirt-2.0.0/src/conf/domain_addr.c
@@ -1362,6 +1362,12 @@ virDomainUSBAddressControllerModelToPort
             return cont->opts.usbopts.ports;
         return 4;
 
+    case VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1:
+    case VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2:
+        if (cont->opts.usbopts.ports != -1)
+            return cont->opts.usbopts.ports;
+        return 8;
+
     case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE:
     case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
         break;
Index: libvirt-2.0.0/src/conf/domain_conf.c
===================================================================
--- libvirt-2.0.0.orig/src/conf/domain_conf.c
+++ libvirt-2.0.0/src/conf/domain_conf.c
@@ -358,6 +358,8 @@ VIR_ENUM_IMPL(virDomainControllerModelUS
               "vt82c686b-uhci",
               "pci-ohci",
               "nec-xhci",
+              "qusb1",
+              "qusb2",
               "none")
 
 VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
Index: libvirt-2.0.0/src/conf/domain_conf.h
===================================================================
--- libvirt-2.0.0.orig/src/conf/domain_conf.h
+++ libvirt-2.0.0/src/conf/domain_conf.h
@@ -676,6 +676,8 @@ typedef enum {
     VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI,
     VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI,
     VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
+    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1,
+    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2,
     VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
 
     VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
Index: libvirt-2.0.0/src/qemu/qemu_command.c
===================================================================
--- libvirt-2.0.0.orig/src/qemu/qemu_command.c
+++ libvirt-2.0.0/src/qemu/qemu_command.c
@@ -133,6 +133,8 @@ VIR_ENUM_IMPL(qemuControllerModelUSB, VI
               "vt82c686b-usb-uhci",
               "pci-ohci",
               "nec-usb-xhci",
+              "qusb1",
+              "qusb2",
               "none");
 
 VIR_ENUM_DECL(qemuDomainFSDriver)