[PATCH rfcv3 11/11] conf: Add support to keep same domid for hard reboot

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

 



After hard reboot, domid is increased by 1 as a new domain.
Hard reboot simulate TD-guest reboot by calling qemuProcessStop
and qemuProcessStart which will release and recreate domain
resource including domid.

Define origin_id to save domid and restore it when recreate
domain. For persistent domain also need to save domid in newDef.

Also add logic to keep same domid when libvirt restart.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxx>
---
 src/conf/domain_conf.c  |  4 ++++
 src/conf/domain_conf.h  |  1 +
 src/qemu/qemu_process.c | 11 +++++++++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 08e82c5380..8c33b335bd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4159,6 +4159,7 @@ void virDomainObjAssignDef(virDomainObj *domain,
         else
             virDomainDefFree(domain->newDef);
         domain->newDef = g_steal_pointer(def);
+        domain->newDef->origin_id = domain->def->id;
         return;
     }
 
@@ -17874,6 +17875,9 @@ virDomainDefParseIDs(virDomainDef *def,
             return -1;
     }
 
+    /* Restore origin_id to support hard reboot */
+    def->origin_id = def->id;
+
     /* Extract domain name */
     if (!(def->name = virXPathString("string(./name[1])", ctxt))) {
         virReportError(VIR_ERR_NO_NAME, NULL);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3b01850eb4..afd54a07eb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2957,6 +2957,7 @@ struct _virDomainVirtioOptions {
 struct _virDomainDef {
     int virtType; /* enum virDomainVirtType */
     int id;
+    int origin_id;
     unsigned char uuid[VIR_UUID_BUFLEN];
 
     unsigned char genid[VIR_UUID_BUFLEN];
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a9bba19852..6ec649a261 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5757,8 +5757,15 @@ qemuProcessInit(virQEMUDriver *driver,
             goto cleanup;
         }
     } else {
-        vm->def->id = qemuDriverAllocateID(driver);
-        qemuDomainSetFakeReboot(vm, false);
+        if (vm->def->origin_id > 0 && priv->hardReboot)
+            vm->def->id = vm->def->origin_id;
+        else
+            vm->def->id = qemuDriverAllocateID(driver);
+        vm->def->origin_id = vm->def->id;
+        if (vm->newDef)
+            vm->newDef->origin_id = vm->def->id;
+
+        qemuDomainSetHardReboot(vm, false);
         qemuDomainSetFakeReboot(vm, false);
         virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_STARTING_UP);
 
-- 
2.34.1
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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