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

[libvirt] [PATCH 2/3] qemu: add VIR_DOMAIN_UNDEFINE_KEEP_NVRAM support



Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy virtuozzo com>
---
 src/qemu/qemu_driver.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 249393a..2f57324 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7341,7 +7341,15 @@ qemuDomainUndefineFlags(virDomainPtr dom,
 
     virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE |
                   VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA |
-                  VIR_DOMAIN_UNDEFINE_NVRAM, -1);
+                  VIR_DOMAIN_UNDEFINE_NVRAM |
+                  VIR_DOMAIN_UNDEFINE_KEEP_NVRAM, -1);
+
+    if ((flags & VIR_DOMAIN_UNDEFINE_NVRAM) &&
+        (flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       "%s", _("cannot both keep and delete nvram"));
+        return -1;
+    }
 
     if (!(vm = qemuDomObjFromDomain(dom)))
         return -1;
@@ -7393,18 +7401,18 @@ qemuDomainUndefineFlags(virDomainPtr dom,
     if (!virDomainObjIsActive(vm) &&
         vm->def->os.loader && vm->def->os.loader->nvram &&
         virFileExists(vm->def->os.loader->nvram)) {
-        if (!(flags & VIR_DOMAIN_UNDEFINE_NVRAM)) {
+        if ((flags & VIR_DOMAIN_UNDEFINE_NVRAM)) {
+            if (unlink(vm->def->os.loader->nvram) < 0) {
+                virReportSystemError(errno,
+                                     _("failed to remove nvram: %s"),
+                                     vm->def->os.loader->nvram);
+                goto cleanup;
+            }
+        } else if (!(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) {
             virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                            _("cannot delete inactive domain with nvram"));
             goto cleanup;
         }
-
-        if (unlink(vm->def->os.loader->nvram) < 0) {
-            virReportSystemError(errno,
-                                 _("failed to remove nvram: %s"),
-                                 vm->def->os.loader->nvram);
-            goto cleanup;
-        }
     }
 
     if (virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm) < 0)
-- 
1.8.3.1


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