]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
libxl: Refactor logic in domain post parse callback
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Mar 2015 14:33:45 +0000 (15:33 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 23 Mar 2015 13:25:14 +0000 (14:25 +0100)
With the current control flow the post parse callback returned success
right away for fully virtualized VMs. To allow adding additional checks
into the post parse callback tweak the conditions so that the function
doesn't return early except for error cases.

To clarify the original piece of code borrow the wording from the commit
message for the patch that introduced the code.

src/libxl/libxl_domain.c

index 407a9bd7496b7d3a8bccfedbcf1064762406ec47..611ccf4214ba67dd7620b3a31ecf7c1970eb56b6 100644 (file)
@@ -546,10 +546,9 @@ libxlDomainDefPostParse(virDomainDefPtr def,
                         virCapsPtr caps ATTRIBUTE_UNUSED,
                         void *opaque ATTRIBUTE_UNUSED)
 {
-    if (STREQ(def->os.type, "hvm"))
-        return 0;
-
-    if (def->nconsoles == 0) {
+    /* Xen PV domains always have a PV console, so add one to the domain config
+     * via post-parse callback if not explicitly specified in the XML. */
+    if (STRNEQ(def->os.type, "hvm") && def->nconsoles == 0) {
         virDomainChrDefPtr chrdef;
 
         if (!(chrdef = virDomainChrDefNew()))