]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: fix usb inputs loop error
authorCédric Bosdonnat <cbosdonnat@suse.com>
Tue, 10 Jan 2017 16:09:03 +0000 (17:09 +0100)
committerCédric Bosdonnat <cbosdonnat@suse.com>
Wed, 11 Jan 2017 16:07:25 +0000 (17:07 +0100)
List indexes where mixed up in the code looping over the USB
input devices.

src/libxl/libxl_conf.c

index ac83b51c7ef9853ab5c0e5e138a08cd571cbeee8..a24f9e052e9fd81ca31e6e94f7f29399e7820efe 100644 (file)
@@ -479,7 +479,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
             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;
@@ -487,7 +488,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
 #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