Skip to contentSkip to conversation

libxl: support dom0

PATCH Jim Fehlig 2 participants 3 messages Jul 6, 2015 – Jul 8, 2015 3 messages not in the archive

lore
Share & tools
lore

Jim Fehlig

author
#1 lore raw
In reply to a message not in the archive
Quoted 73 lines · Jim Fehlig

In Xen, dom0 is really just another domain that supports ballooning, adding/removing devices, changing vcpu configuration, etc. This patch adds support to the libxl driver for managing dom0. Note that the legacy xend driver has long supported managing dom0.

Operations that are not supported on dom0 are filtered in libvirt where a sensible error is reported. Errors from libxl are not always helpful. E.g., attempting a save on dom0 results in

2015-06-23 15:25:05 MDT libxl: debug: libxl_dom.c:1570:libxl__toolstack_save: domain=0 toolstack data size=8
2015-06-23 15:25:05 MDT libxl: debug: libxl.c:979:do_libxl_domain_suspend: ao 0x7f7e68000b70: inprogress: poller=0x7f7e68000930, flags=i
2015-06-23 15:25:05 MDT libxl-save-helper: debug: starting save: Success
2015-06-23 15:25:05 MDT xc: detail: xc_domain_save_suse: starting save of domid 0
2015-06-23 15:25:05 MDT xc: error: Couldn't map live_shinfo (3 = No such process): Internal error
2015-06-23 15:25:05 MDT xc: detail: Save exit of domid 0 with errno=3
2015-06-23 15:25:05 MDT libxl-save-helper: debug: complete r=1: No such process
2015-06-23 15:25:05 MDT libxl: error: libxl_dom.c:1876:libxl__xc_domain_save_done: saving domain: domain did not respond to suspend request: No such process
2015-06-23 15:25:05 MDT libxl: error: libxl_dom.c:2033:remus_teardown_done: Remus: failed to teardown device for guest with domid 0, rc -8
---
  src/libxl/libxl_driver.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 95 insertions(+)
src/libxl/libxl_driver.c +34 -0
index 149ef70..d0b76ac 100644
@@ -79,6 +79,15 @@ VIR_LOG_INIT("libxl.libxl_driver");
  /* Number of Xen scheduler parameters */
  #define XEN_SCHED_CREDIT_NPARAM   2
 
+#define LIBXL_CHECK_DOM0_GOTO(name, label)                               \
+    do {                                                                  \
+        if (STREQ_NULLABLE(name, "Domain-0")) {                           \
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",               \
+                           _("Domain-0 does not support requested operation")); \
+            goto label;                                                   \
+        }                                                                 \
+    } while (0)
+
 
  static libxlDriverPrivatePtr libxl_driver;
 
@@ -501,6 +510,62 @@ const struct libxl_event_hooks ev_hooks = {
  };
 
  static int
+libxlAddDom0(libxlDriverPrivatePtr driver)
+{
+    libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+    virDomainDefPtr def = NULL;
+    virDomainObjPtr vm = NULL;
+    virDomainDefPtr oldDef = NULL;
+    libxl_dominfo d_info;
+    int ret = -1;
+
+    libxl_dominfo_init(&d_info);
+
+    /* Ensure we have a dom0 */
+    if (libxl_domain_info(cfg->ctx, &d_info, 0) != 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("unable to get Domain-0 information from libxenlight"));
+        goto cleanup;
+    }
+
+    if (!(def = virDomainDefNew()))
+        goto cleanup;
+
+    def->id = 0;
+    def->virtType = VIR_DOMAIN_VIRT_XEN;
+    if (VIR_STRDUP(def->name, "Domain-0") < 0)
+        goto cleanup;

src/libxl/libxl_driver.c const struct libxl_event_hooks ev_hooks = { · line 547

Quoted 10 lines
src/libxl/libxl_driver.c +10 -0
+
+    def->os.type = VIR_DOMAIN_OSTYPE_XEN;
+
+    if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid) < 0)
+        goto cleanup;
+
+    vm->def->vcpus = d_info.vcpu_online;
+    vm->def->maxvcpus = d_info.vcpu_max_id + 1;
+    vm->def->mem.cur_balloon = d_info.current_memkb;
+    vm->def->mem.max_balloon = d_info.max_memkb;

Opps. Before sending the patch, but after testing it again, I moved the call to libxl_domain_info to the beginning of this function. I also moved setting the vcpu and memory info earlier, but

src/libxl/libxl_driver.c const struct libxl_event_hooks ev_hooks = { · line 556

Quoted 9 lines
src/libxl/libxl_driver.c +9 -0
+
+    if (!(vm = virDomainObjListAdd(driver->domains, def,
+                                   driver->xmlopt,
+                                   0,
+                                   &oldDef)))
+        goto cleanup;
+
+    def = NULL;
+    ret = 0;

before getting a virDomainObj - ouch. Consider the following obvious fix squashed in

src/libxl/libxl_driver.c +8 -7
index d0b76ac..c0dd00b 100644
@@ -541,18 +541,19 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
     if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid) < 0)
         goto cleanup;
 
+    if (!(vm = virDomainObjListAdd(driver->domains, def,
+                                   driver->xmlopt,
+                                   0,
+                                   &oldDef)))
+        goto cleanup;
+
+    def = NULL;
+
     vm->def->vcpus = d_info.vcpu_online;
     vm->def->maxvcpus = d_info.vcpu_max_id + 1;
     vm->def->mem.cur_balloon = d_info.current_memkb;
     vm->def->mem.max_balloon = d_info.max_memkb;
 
-    if (!(vm = virDomainObjListAdd(driver->domains, def,
-                                   driver->xmlopt,
-                                   0,
-                                   &oldDef)))
-        goto cleanup;
-
-    def = NULL;
     ret = 0;
 
  cleanup:

Regards,
Jim

#3 lore raw
In reply to a message not in the archive
Quoted 151 lines · Jim Fehlig
Quoted 93 lines · Jim Fehlig

In Xen, dom0 is really just another domain that supports ballooning, adding/removing devices, changing vcpu configuration, etc. This patch adds support to the libxl driver for managing dom0. Note that the legacy xend driver has long supported managing dom0.

Operations that are not supported on dom0 are filtered in libvirt where a sensible error is reported. Errors from libxl are not always helpful. E.g., attempting a save on dom0 results in

2015-06-23 15:25:05 MDT libxl: debug:
libxl_dom.c:1570:libxl__toolstack_save: domain=0 toolstack data size=8
2015-06-23 15:25:05 MDT libxl: debug:
libxl.c:979:do_libxl_domain_suspend: ao 0x7f7e68000b70: inprogress:
poller=0x7f7e68000930, flags=i
2015-06-23 15:25:05 MDT libxl-save-helper: debug: starting save: Success
2015-06-23 15:25:05 MDT xc: detail: xc_domain_save_suse: starting save
of domid 0
2015-06-23 15:25:05 MDT xc: error: Couldn't map live_shinfo (3 = No
such process): Internal error
2015-06-23 15:25:05 MDT xc: detail: Save exit of domid 0 with errno=3
2015-06-23 15:25:05 MDT libxl-save-helper: debug: complete r=1: No
such process
2015-06-23 15:25:05 MDT libxl: error:
libxl_dom.c:1876:libxl__xc_domain_save_done: saving domain: domain did
not respond to suspend request: No such process
2015-06-23 15:25:05 MDT libxl: error:

libxl_dom.c:2033:remus_teardown_done: Remus: failed to teardown device for guest with domid 0, rc -8

---
  src/libxl/libxl_driver.c | 95
++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 95 insertions(+)
src/libxl/libxl_driver.c +3 -0
index 149ef70..d0b76ac 100644
@@ -79,6 +79,15 @@ VIR_LOG_INIT("libxl.libxl_driver");
  /* Number of Xen scheduler parameters */
  #define XEN_SCHED_CREDIT_NPARAM   2
  +#define LIBXL_CHECK_DOM0_GOTO(name,
 label)                               \
+    do
 {                                                                  \
+        if (STREQ_NULLABLE(name, "Domain-0"))
 {                           \
+            virReportError(VIR_ERR_OPERATION_INVALID,

"%s", \
+ _("Domain-0 does not support requested
operation")); \
+ goto
label; \
+
} \

src/libxl/libxl_driver.c +17 -0
+    } while (0)
+
    static libxlDriverPrivatePtr libxl_driver;
  @@ -501,6 +510,62 @@ const struct libxl_event_hooks ev_hooks = {
  };
    static int
+libxlAddDom0(libxlDriverPrivatePtr driver)
+{
+    libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+    virDomainDefPtr def = NULL;
+    virDomainObjPtr vm = NULL;
+    virDomainDefPtr oldDef = NULL;
+    libxl_dominfo d_info;
+    int ret = -1;
+
+    libxl_dominfo_init(&d_info);
+
+    /* Ensure we have a dom0 */
+    if (libxl_domain_info(cfg->ctx, &d_info, 0) != 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("unable to get Domain-0 information

from libxenlight"));

src/libxl/libxl_driver.c +14 -0
+        goto cleanup;
+    }
+
+    if (!(def = virDomainDefNew()))
+        goto cleanup;
+
+    def->id = 0;
+    def->virtType = VIR_DOMAIN_VIRT_XEN;
+    if (VIR_STRDUP(def->name, "Domain-0") < 0)
+        goto cleanup;
+
+    def->os.type = VIR_DOMAIN_OSTYPE_XEN;
+
+    if (virUUIDParse("00000000-0000-0000-0000-000000000000",

def->uuid) < 0)

src/libxl/libxl_driver.c

Quoted 6 lines
src/libxl/libxl_driver.c +6 -0
+        goto cleanup;
+
+    vm->def->vcpus = d_info.vcpu_online;
+    vm->def->maxvcpus = d_info.vcpu_max_id + 1;
+    vm->def->mem.cur_balloon = d_info.current_memkb;
+    vm->def->mem.max_balloon = d_info.max_memkb;

Opps. Before sending the patch, but after testing it again, I moved the call to libxl_domain_info to the beginning of this function. I also moved setting the vcpu and memory info earlier, but

src/libxl/libxl_driver.c

Quoted 9 lines
src/libxl/libxl_driver.c +9 -0
+
+    if (!(vm = virDomainObjListAdd(driver->domains, def,
+                                   driver->xmlopt,
+                                   0,
+                                   &oldDef)))
+        goto cleanup;
+
+    def = NULL;
+    ret = 0;

before getting a virDomainObj - ouch. Consider the following obvious fix squashed in

src/libxl/libxl_driver.c +8 -7
index d0b76ac..c0dd00b 100644
@@ -541,18 +541,19 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
     if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid)
 < 0)
         goto cleanup;
 
+    if (!(vm = virDomainObjListAdd(driver->domains, def,
+                                   driver->xmlopt,
+                                   0,
+                                   &oldDef)))
+        goto cleanup;
+
+    def = NULL;
+
     vm->def->vcpus = d_info.vcpu_online;
     vm->def->maxvcpus = d_info.vcpu_max_id + 1;
     vm->def->mem.cur_balloon = d_info.current_memkb;
     vm->def->mem.max_balloon = d_info.max_memkb;
 
-    if (!(vm = virDomainObjListAdd(driver->domains, def,
-                                   driver->xmlopt,
-                                   0,
-                                   &oldDef)))
-        goto cleanup;
-
-    def = NULL;
     ret = 0;
 

cleanup:

Quoted 3 lines

Regards,
Jim

ACK with this squashed in.

Michal

author
#5 lore raw
In reply to a message not in the archive
Quoted 7 lines · Michal Privoznik
Quoted 6 lines · Jim Fehlig
Quoted 5 lines · Jim Fehlig

In Xen, dom0 is really just another domain that supports ballooning, adding/removing devices, changing vcpu configuration, etc. This patch adds support to the libxl driver for managing dom0. Note that the legacy xend driver has long supported managing dom0.

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

Operations that are not supported on dom0 are filtered in libvirt where a sensible error is reported. Errors from libxl are not always helpful. E.g., attempting a save on dom0 results in

ACK with this squashed in.

Pushed. Thanks for the review!

Regards,
Jim