]> xenbits.xensource.com Git - libvirt.git/commitdiff
Ensure VirtualBox domain IDs start from 1 instead of 0
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 21 Apr 2009 19:13:23 +0000 (19:13 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 21 Apr 2009 19:13:23 +0000 (19:13 +0000)
ChangeLog
po/POTFILES.in
src/vbox/vbox_tmpl.c

index a289775392af2b0ad82e6e084318ac943ab75f00..28bda90a0fd9fbe00daf8f0f8a548fe6756b8ee1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Apr 21 14:39:03 BST 2009 Daniel P. Berrange <berrange@redhat.com>
+
+       * po/POTFILES.in: Add vbox_tmpl.c file
+       * src/vbox/vbox_tmpl.c: Adjust domain IDs to start from 1
+       instead of 0, refuse domain ID 0.
+
 Tue Apr 21 20:58:50 CEST 2009 Daniel Veillard <veillard@redhat.com>
 
        * src/network_conf.c src/network_conf.h: add dynamic bridge names
index dc86835382d9e03b1d3fe224f3fc7f995977d1bc..831f79669b20adcbc3cf1efc9580fd1c13b6c6f8 100644 (file)
@@ -38,6 +38,7 @@ src/uml_conf.c
 src/uml_driver.c
 src/util.c
 src/uuid.c
+src/vbox/vbox_tmpl.c
 src/virsh.c
 src/virterror.c
 src/xen_inotify.c
index 52020e43726023d6ac5490f29aee5bb76501f0c1..bb124b9bdc42247b89d4b80e6d6bfae39eb5e535 100644 (file)
@@ -434,7 +434,7 @@ static int vboxListDomains(virConnectPtr conn, int *ids, int nids) {
                     if ((state == MachineState_Running) ||
                         (state == MachineState_Paused) ) {
                         ret++;
-                        ids[j++] = i;
+                        ids[j++] = i + 1;
                     }
                 }
             }
@@ -535,6 +535,15 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
     PRUint32 state;
     int i;
 
+    /* Internal vbox IDs start from 0, the public libvirt ID
+     * starts from 1, so refuse id==0, and adjust the rest*/
+    if (id == 0) {
+        vboxError(conn, VIR_ERR_NO_DOMAIN,
+                  _("no domain with matching id %d"), id);
+        return NULL;
+    }
+    id = id - 1;
+
     if(data->vboxObj) {
         rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
         if (NS_FAILED(rc)) {
@@ -568,7 +577,7 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
 
                         dom = virGetDomain(conn, machineName, iidl);
                         if (dom)
-                            dom->id = id;
+                            dom->id = id + 1;
 
                         /* Cleanup all the XPCOM allocated stuff here */
                         g_pVBoxFuncs->pfnComUnallocMem(iid);
@@ -645,7 +654,7 @@ static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned ch
                     if (dom)
                         if ((state == MachineState_Running) ||
                             (state == MachineState_Paused) )
-                            dom->id = i;
+                            dom->id = i + 1;
                 }
 
                 if (iid) {
@@ -725,7 +734,7 @@ static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name)
                     if (dom)
                         if ((state == MachineState_Running) ||
                             (state == MachineState_Paused) )
-                            dom->id = i;
+                            dom->id = i + 1;
                 }
 
                 if (machineName) {
@@ -2311,7 +2320,7 @@ static int vboxDomainCreate(virDomainPtr dom) {
                                 ret = -1;
                             } else {
                                 /* all ok set the domid */
-                                dom->id = i;
+                                dom->id = i + 1;
                                 ret = 0;
                             }
                         }