virDomainDefPtr def; /* VM definition */
virCapsPtr caps; /* VM capabilities */
virDomainXMLOptionPtr xmlopt; /* XML parser data */
+ char *virtType; /* type of hypervisor (eg qemu, xen, lxc) */
char *os; /* type of os (eg hvm, xen, exe) */
virArch arch; /* machine architecture */
char *newfile; /* newly added file */
virObjectUnref(ctl->caps);
virObjectUnref(ctl->xmlopt);
VIR_FREE(ctl->files);
+ VIR_FREE(ctl->virtType);
VIR_FREE(ctl->os);
VIR_FREE(ctl->newfile);
/*
* Parse the xml we received to fill in the following:
+ * ctl->virtType
* ctl->os
* ctl->arch
*
if (verify_xpath_context(ctxt) != 0)
goto cleanup;
+ ctl->virtType = virXPathString("string(./@type)", ctxt);
+ if (!ctl->virtType) {
+ vah_error(ctl, 0, _("domain type is not defined"));
+ goto cleanup;
+ }
ctl->os = virXPathString("string(./os/type[1])", ctxt);
if (!ctl->os) {
vah_error(ctl, 0, _("os.type is not defined"));
static int
get_definition(vahControl * ctl, const char *xmlStr)
{
- int rc = -1, ostype;
+ int rc = -1, ostype, virtType;
virCapsGuestPtr guest; /* this is freed when caps is freed */
/*
goto exit;
}
+ if ((virtType = virDomainVirtTypeFromString(ctl->virtType)) < 0) {
+ vah_error(ctl, 0, _("unknown virtualization type"));
+ goto exit;
+ }
+
+ if (virCapabilitiesAddGuestDomain(guest,
+ virtType,
+ NULL,
+ NULL,
+ 0,
+ NULL) == NULL) {
+ vah_error(ctl, 0, _("could not allocate memory"));
+ goto exit;
+ }
+
ctl->def = virDomainDefParseString(xmlStr,
ctl->caps, ctl->xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE);
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,<type arch='x86_64' machine='pc'>hvm</type>,,g" "$template_xml" > "$test_xml"
testme "1" "-c with no os.type" "-c -u $valid_uuid" "$test_xml"
-sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,<type arch='x86_64' machine='pc'>hvm</type>,<type>hvm</type>,g" "$template_xml" > "$test_xml"
-testme "1" "-c with no architecture" "-c -u $valid_uuid" "$test_xml"
-
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,hvm</type>,hvm_invalid</type>,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid hvm" "-c -u $valid_uuid" "$test_xml"