File 162bb0e7b-libxl-fix-usb-inputs-loop-error.patch of Package libvirt.6159

From 162bb0e7b1ed64300b838dac9532c3c38bdaa234 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com>
Date: Tue, 10 Jan 2017 17:09:03 +0100
Subject: [PATCH] libxl: fix usb inputs loop error

List indexes where mixed up in the code looping over the USB
input devices.
---
 src/libxl/libxl_conf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: libvirt-2.0.0/src/libxl/libxl_conf.c
===================================================================
--- libvirt-2.0.0.orig/src/libxl/libxl_conf.c
+++ libvirt-2.0.0/src/libxl/libxl_conf.c
@@ -463,7 +463,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr de
             if (VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) < 0)
                 return -1;
 #else
-            if (i > 1) {
+            nusbdevice++;
+            if (nusbdevice > 1) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                         _("libxenlight supports only one input device"));
                 return -1;
@@ -471,7 +472,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr de
 #endif
 
 #ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
-            usbdevice = &b_info->u.hvm.usbdevice_list[i];
+            usbdevice = &b_info->u.hvm.usbdevice_list[nusbdevice - 1];
 #else
             usbdevice = &b_info->u.hvm.usbdevice;
 #endif