From 19e85d845495fa022abe3e7d0599d8329396c1c9 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 16 Mar 2015 15:33:45 +0100 Subject: [PATCH] libxl: Refactor logic in domain post parse callback 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 407a9bd749..611ccf4214 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -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()))