Kiarie Kahurani wrote:
introduce function
xenFormatXMGeneralMeta(virConfPtr conf,......);
which parses uuid and name instead
Sorry for the delay, but it took me longer than expected to rebase the
series after some initial changes. No fault of yours, just too much
indecision on my part.
Signed-off-by: Kiarie Kahurani <davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 53 ++++++++++++++++++++++++++++++++---------------------
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 8238026..62d7f8f 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1337,8 +1337,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
}
-static
-int xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l)
+static int
+xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l)
All of these whitespace changes should be done in a separate cleanup patch.
{
virConfValuePtr value = NULL;
@@ -1460,8 +1460,10 @@ xenFormatXMDisk(virConfValuePtr list,
return -1;
}
-static int xenFormatXMSerial(virConfValuePtr list,
- virDomainChrDefPtr serial)
+
+static int
+xenFormatXMSerial(virConfValuePtr list,
+ virDomainChrDefPtr serial)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp;
@@ -1497,10 +1499,12 @@ static int xenFormatXMSerial(virConfValuePtr list,
return -1;
}
-static int xenFormatXMNet(virConnectPtr conn,
- virConfValuePtr list,
- virDomainNetDefPtr net,
- int hvm, int xendConfigVersion)
+
+static int
+xenFormatXMNet(virConnectPtr conn,
+ virConfValuePtr list,
+ virDomainNetDefPtr net,
+ int hvm, int xendConfigVersion)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp;
@@ -1602,10 +1606,8 @@ static int xenFormatXMNet(virConnectPtr conn,
}
-
static int
-xenFormatXMPCI(virConfPtr conf,
- virDomainDefPtr def)
+xenFormatXMPCI(virConfPtr conf, virDomainDefPtr def)
{
virConfValuePtr pciVal = NULL;
@@ -1671,32 +1673,41 @@ xenFormatXMPCI(virConfPtr conf,
}
+static int
+xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def)
+{
+ char uuid[VIR_UUID_STRING_BUFLEN];
+
+ if (xenXMConfigSetString(conf, "name", def->name) < 0)
+ return -1;
+
+ virUUIDFormat(def->uuid, uuid);
+ if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
+ return -1;
+
+ return 0;
+}
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
-virConfPtr xenFormatXM(virConnectPtr conn,
- virDomainDefPtr def,
- int xendConfigVersion)
+virConfPtr
+xenFormatXM(virConnectPtr conn,
+ virDomainDefPtr def,
+ int xendConfigVersion)
{
virConfPtr conf = NULL;
int hvm = 0, vmlocaltime = 0;
size_t i;
char *cpus = NULL;
const char *lifecycle;
- char uuid[VIR_UUID_STRING_BUFLEN];
virConfValuePtr diskVal = NULL;
virConfValuePtr netVal = NULL;
if (!(conf = virConfNew()))
goto cleanup;
-
- if (xenXMConfigSetString(conf, "name", def->name) < 0)
- goto cleanup;
-
- virUUIDFormat(def->uuid, uuid);
- if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
+ if (xenFormatXMGeneralMeta(conf, def) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "maxmem",
But this last hunk, which is the meat of the patch, looks good.
The parse refactoring has been committed, so I'd like to commit the
format refactoring too, before reworking the layout of the xenxs
directory. I'll remove the unrelated whitespace changes before pushing.
Regards,
Jim