[PATCH 5/7] qemu: Support set bootindex to -1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Enable bootindex can be set to -1, it means cancel the device's bootindex.
Change bootindex's type from unsigned int to int and modify other related
codes concered with type.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@xxxxxxxxxx>
---
 src/conf/device_conf.h      |  4 ++--
 src/conf/domain_conf.c      | 15 ++++++++++-----
 src/conf/domain_postparse.c |  2 +-
 src/qemu/qemu_command.c     | 38 ++++++++++++++++++-------------------
 src/qemu/qemu_process.c     |  8 ++++----
 src/qemu/qemu_validate.c    |  6 +++---
 6 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index f2907dc596..a9df2e6e5d 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -139,11 +139,11 @@ struct _virDomainDeviceInfo {
     char *romfile;
     /* bootIndex is only used for disk, network interface, hostdev
      * and redirdev devices */
-    unsigned int bootIndex;
+    int bootIndex;
     /* 'effectiveBootIndex' is same as 'bootIndex' (if provided in the XML) but
      * not formatted back. This allows HV drivers to update it if <os><boot ..
      * is present. */
-    unsigned int effectiveBootIndex;
+    int effectiveBootIndex;
     /* Valid for any PCI device. Can be used for NIC to get
      * stable numbering in Linux */
     unsigned int acpiIndex;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c904d9c63d..fe7e5f9116 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5093,7 +5093,7 @@ virDomainDeviceInfoFormat(virBuffer *buf,
     g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
 
     if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
-        virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
+        virBufferAsprintf(buf, "<boot order='%d'", info->bootIndex);
 
         if (info->loadparm)
             virBufferAsprintf(buf, " loadparm='%s'", info->loadparm);
@@ -5254,10 +5254,15 @@ virDomainDeviceBootParseXML(xmlNodePtr node,
 {
     g_autofree char *loadparm = NULL;
 
-    if (virXMLPropUInt(node, "order", 10,
-                       VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
-                       &info->bootIndex) < 0)
+    if (virXMLPropInt(node, "order", 10,
+                      VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
+                      &info->bootIndex, -1) < 0)
         return -1;
+    if (info->bootIndex == 0 || info->bootIndex < -1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("incorrect boot order '%d', expecting positive integer or -1"),
+                       info->bootIndex);
+    }
 
     info->effectiveBootIndex = info->bootIndex;
 
@@ -27652,7 +27657,7 @@ virDomainDeviceInfoCheckBootIndex(virDomainDef *def G_GNUC_UNUSED,
 
     if (info->bootIndex == data->newInfo->bootIndex) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("boot order %u is already used by another device"),
+                       _("boot order %d is already used by another device"),
                        data->newInfo->bootIndex);
         return -1;
     }
diff --git a/src/conf/domain_postparse.c b/src/conf/domain_postparse.c
index df59de2d0d..9810de7437 100644
--- a/src/conf/domain_postparse.c
+++ b/src/conf/domain_postparse.c
@@ -1041,7 +1041,7 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNUC_UNUSED,
          */
         return 0;
     }
-    order = g_strdup_printf("%u", info->bootIndex);
+    order = g_strdup_printf("%d", info->bootIndex);
 
     if (virHashLookup(bootHash, order)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a31b8ee438..e124800bcc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1765,7 +1765,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def,
     virTristateSwitch shareRW = VIR_TRISTATE_SWITCH_ABSENT;
     g_autofree char *chardev = NULL;
     g_autofree char *drive = NULL;
-    unsigned int bootindex = 0;
+    int bootindex = 0;
     unsigned int logical_block_size = 0;
     unsigned int physical_block_size = 0;
     g_autoptr(virJSONValue) wwn = NULL;
@@ -1951,7 +1951,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def,
                               "S:drive", drive,
                               "S:chardev", chardev,
                               "s:id", disk->info.alias,
-                              "p:bootindex", bootindex,
+                              "z:bootindex", bootindex,
                               "p:logical_block_size", logical_block_size,
                               "p:physical_block_size", physical_block_size,
                               "A:wwn", &wwn,
@@ -2019,25 +2019,25 @@ qemuCommandAddExtDevice(virCommand *cmd,
 
 static void
 qemuBuildFloppyCommandLineControllerOptionsImplicit(virCommand *cmd,
-                                                    unsigned int bootindexA,
-                                                    unsigned int bootindexB)
+                                                    int bootindexA,
+                                                    int bootindexB)
 {
     if (bootindexA > 0) {
         virCommandAddArg(cmd, "-global");
-        virCommandAddArgFormat(cmd, "isa-fdc.bootindexA=%u", bootindexA);
+        virCommandAddArgFormat(cmd, "isa-fdc.bootindexA=%d", bootindexA);
     }
 
     if (bootindexB > 0) {
         virCommandAddArg(cmd, "-global");
-        virCommandAddArgFormat(cmd, "isa-fdc.bootindexB=%u", bootindexB);
+        virCommandAddArgFormat(cmd, "isa-fdc.bootindexB=%d", bootindexB);
     }
 }
 
 
 static int
 qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand *cmd,
-                                                    unsigned int bootindexA,
-                                                    unsigned int bootindexB,
+                                                    int bootindexA,
+                                                    int bootindexB,
                                                     const virDomainDef *def,
                                                     virQEMUCaps *qemuCaps)
 {
@@ -2045,8 +2045,8 @@ qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand *cmd,
 
     if (virJSONValueObjectAdd(&props,
                               "s:driver", "isa-fdc",
-                              "p:bootindexA", bootindexA,
-                              "p:bootindexB", bootindexB,
+                              "z:bootindexA", bootindexA,
+                              "z:bootindexB", bootindexB,
                               NULL) < 0)
         return -1;
 
@@ -2062,8 +2062,8 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
                                             const virDomainDef *def,
                                             virQEMUCaps *qemuCaps)
 {
-    unsigned int bootindexA = 0;
-    unsigned int bootindexB = 0;
+    int bootindexA = 0;
+    int bootindexB = 0;
     bool hasfloppy = false;
     size_t i;
 
@@ -2286,7 +2286,7 @@ qemuBuildVHostUserFsDevProps(virDomainFSDef *fs,
                               "s:chardev", chardev_alias,
                               "P:queue-size", fs->queue_size,
                               "s:tag", fs->dst,
-                              "p:bootindex", fs->info.bootIndex,
+                              "z:bootindex", fs->info.bootIndex,
                               NULL) < 0)
         return NULL;
 
@@ -3762,7 +3762,7 @@ qemuBuildNicDevProps(virDomainDef *def,
                               "s:netdev", netdev,
                               "s:id", net->info.alias,
                               "s:mac", macaddr,
-                              "p:bootindex", net->info.effectiveBootIndex,
+                              "z:bootindex", net->info.effectiveBootIndex,
                               NULL) < 0)
         return NULL;
 
@@ -4576,7 +4576,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
                               "s:driver", "vfio-pci",
                               "s:host", host,
                               "s:id", dev->info->alias,
-                              "p:bootindex", dev->info->effectiveBootIndex,
+                              "z:bootindex", dev->info->effectiveBootIndex,
                               "S:failover_pair_id", failover_pair_id,
                               NULL) < 0)
         return NULL;
@@ -4643,7 +4643,7 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def,
                               "p:hostbus", hostbus,
                               "p:hostaddr", hostaddr,
                               "s:id", dev->info->alias,
-                              "p:bootindex",  dev->info->bootIndex,
+                              "z:bootindex",  dev->info->bootIndex,
                               "T:guest-reset", guestReset,
                               "T:guest-resets-all", guestResetsAll,
                               NULL) < 0)
@@ -4733,7 +4733,7 @@ qemuBuildSCSIHostdevDevProps(const virDomainDef *def,
                               "s:driver", "scsi-generic",
                               "s:drive", backendAlias,
                               "s:id", dev->info->alias,
-                              "p:bootindex", dev->info->bootIndex,
+                              "z:bootindex", dev->info->bootIndex,
                               NULL) < 0)
         return NULL;
 
@@ -4831,7 +4831,7 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def,
                               "s:sysfsdev", mdevPath,
                               "S:display", qemuOnOffAuto(mdevsrc->display),
                               "B:ramfb", ramfb,
-                              "p:bootindex", dev->info->bootIndex,
+                              "z:bootindex", dev->info->bootIndex,
                               NULL) < 0)
         return NULL;
 
@@ -9022,7 +9022,7 @@ qemuBuildRedirdevDevProps(const virDomainDef *def,
                               "s:chardev", chardev,
                               "s:id", dev->info.alias,
                               "S:filter", filter,
-                              "p:bootindex", dev->info.bootIndex,
+                              "z:bootindex", dev->info.bootIndex,
                               NULL) < 0)
         return NULL;
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 32f03ff79a..327307de9c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6264,10 +6264,10 @@ static void
 qemuProcessPrepareDeviceBootorder(virDomainDef *def)
 {
     size_t i;
-    unsigned int bootCD = 0;
-    unsigned int bootFloppy = 0;
-    unsigned int bootDisk = 0;
-    unsigned int bootNetwork = 0;
+    int bootCD = 0;
+    int bootFloppy = 0;
+    int bootDisk = 0;
+    int bootNetwork = 0;
 
     if (def->os.nBootDevs == 0)
         return;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 6403266559..c3ecd03dfb 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2520,7 +2520,7 @@ qemuValidateDomainMdevDefVFIOPCI(const virDomainHostdevDef *hostdev,
     }
 
     /* VFIO-PCI does not support boot */
-    if (hostdev->info->bootIndex) {
+    if (hostdev->info->bootIndex > 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("booting from assigned devices is not "
                          "supported by mediated devices of "
@@ -2576,7 +2576,7 @@ qemuValidateDomainMdevDefVFIOAP(const virDomainHostdevDef *hostdev,
     }
 
     /* VFIO-AP does not support boot */
-    if (hostdev->info->bootIndex) {
+    if (hostdev->info->bootIndex > 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("booting from assigned devices is not "
                          "supported by mediated devices of "
@@ -2687,7 +2687,7 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev,
             break;
 
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
-            if (hostdev->info->bootIndex) {
+            if (hostdev->info->bootIndex > 0) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("booting from assigned devices is not "
                                  "supported by vhost SCSI devices"));
-- 
2.33.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux