[PATCH 7/7] qemu: Reserve bootindex = -1 in virDomainDeviceDefCopy

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

 



Since we don't format bootindex's xml when it is -1, we will lost bootindex
if it is set to -1. So we should reserve bootindex = -1 in virDomainDeviceDefCopy
to save the message that we cancel a bootindex set.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 23 ++++++++++++++++++++---
 src/conf/domain_conf.h |  4 ++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fe7e5f9116..d35fd995e4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28651,6 +28651,7 @@ virDomainDeviceDefCopy(virDomainDeviceDef *src,
                        virDomainXMLOption *xmlopt,
                        void *parseOpaque)
 {
+    virDomainDeviceDef* ret;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     int flags = VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_SECURE;
     int rc = -1;
@@ -28746,9 +28747,13 @@ virDomainDeviceDefCopy(virDomainDeviceDef *src,
         return NULL;
 
     xmlStr = virBufferContentAndReset(&buf);
-    return virDomainDeviceDefParse(xmlStr, def, xmlopt, parseOpaque,
-                                   VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                   VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
+    ret = virDomainDeviceDefParse(xmlStr, def, xmlopt, parseOpaque,
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE |
+                                  VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
+    if (ret)
+        virDomainDeviceDefCopyBootIndex(ret, src);
+    
+    return ret;
 }
 
 
@@ -30669,3 +30674,15 @@ virDomainDefHasSpiceGraphics(const virDomainDef *def)
 
     return false;
 }
+
+void
+virDomainDeviceDefCopyBootIndex(virDomainDeviceDef *dest, virDomainDeviceDef *src)
+{
+    if (src->type == VIR_DOMAIN_DEVICE_DISK &&
+        src->data.disk->info.bootIndex == -1)
+        dest->data.disk->info.bootIndex = src->data.disk->info.bootIndex;
+
+    if (src->type == VIR_DOMAIN_DEVICE_NET &&
+        src->data.net->info.bootIndex == -1)
+        dest->data.net->info.bootIndex = src->data.net->info.bootIndex;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2b1497d78d..8a152df692 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -4330,3 +4330,7 @@ virDomainObjGetMessages(virDomainObj *vm,
 
 bool
 virDomainDefHasSpiceGraphics(const virDomainDef *def);
+
+void 
+virDomainDeviceDefCopyBootIndex(virDomainDeviceDef *dest,
+                                virDomainDeviceDef *src);
-- 
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