[PATCH] OpenVZ: take veid from vmdef->name when defining new domains

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

 



Hi,
We currently use the next free veid although there's one given in the
domain xml. This currently breaks defining new domains since vmdef->name
and veid don't match leading to the following error later on:

    error: Failed to define domain from 110.xml
    error: internal error Could not set UUID

Since silently ignoring vmdef->name is not nice respect it instead. We
avoid veid collisions in the upper levels already.

O.k. to apply?
 -- Guido
>From 6a83bcb0743feb87a9b2d3bdca7960284d0efb04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@xxxxxxxxxxx>
Date: Sun, 28 Nov 2010 22:52:44 +0100
Subject: [PATCH] OpenVZ: take veid from vmdef->name when defining new domains

We currently use the next free veid although there's one given in the
domain xml. This currently breaks defining new domains since vmdef->name
and veid don't match leading to the following error later on:

    error: Failed to define domain from 110.xml
    error: internal error Could not set UUID

Since silently ignoring vmdef->name is not nice respect it instead. We
avoid veid collisions in the upper levels already.
---
 src/openvz/openvz_driver.c |   40 ++--------------------------------------
 1 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 807bb7c..6189fc1 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -103,10 +103,6 @@ openvzDomainDefineCmd(const char *args[],
                       int maxarg, virDomainDefPtr vmdef)
 {
     int narg;
-    int veid;
-    int max_veid;
-    char str_id[INT_BUFSIZE_BOUND(max_veid)];
-    FILE *fp;
 
     for (narg = 0; narg < maxarg; narg++)
         args[narg] = NULL;
@@ -116,6 +112,7 @@ openvzDomainDefineCmd(const char *args[],
                     _("Container is not defined"));
         return -1;
     }
+
 #define ADD_ARG(thisarg)                                                \
     do {                                                                \
         if (narg >= maxarg)                                             \
@@ -136,36 +133,7 @@ openvzDomainDefineCmd(const char *args[],
     ADD_ARG_LIT("--quiet");
     ADD_ARG_LIT("create");
 
-    if ((fp = popen(VZLIST " -a -ovpsid -H 2>/dev/null", "r")) == NULL) {
-        openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
-                    _("popen  failed"));
-        return -1;
-    }
-    max_veid = 0;
-    while (!feof(fp)) {
-        if (fscanf(fp, "%d\n", &veid) != 1) {
-            if (feof(fp))
-                break;
-
-            openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
-                        _("Failed to parse vzlist output"));
-            goto cleanup;
-        }
-        if (veid > max_veid) {
-            max_veid = veid;
-        }
-    }
-    VIR_FORCE_FCLOSE(fp);
-
-    if (max_veid == 0) {
-        max_veid = 100;
-    } else {
-        max_veid++;
-    }
-
-    snprintf(str_id, sizeof(str_id), "%d", max_veid);
-    ADD_ARG_LIT(str_id);
-
+    ADD_ARG_LIT(vmdef->name);
     ADD_ARG_LIT("--name");
     ADD_ARG_LIT(vmdef->name);
 
@@ -189,10 +157,6 @@ no_memory:
                 _("Could not put argument to %s"), VZCTL);
     return -1;
 
-cleanup:
-    VIR_FORCE_FCLOSE(fp);
-    return -1;
-
 #undef ADD_ARG
 #undef ADD_ARG_LIT
 }
-- 
1.7.2.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]