libvirt/24f3c2f-virt-aa-helper-fix-caps.patch
Cédric Bosdonnat 37e0137a03 Accepting request 315860 from home:cbosdonnat:branches:Virtualization
Tue Jul  10 13:29:51 UTC 2015 - cbosdonnat@suse.com
- Fixed virt-aa-helper bugs preventing virt-sandbox to work.
  24f3c2f-virt-aa-helper-fix-caps.patch
  61dab0f-virt-aa-helper-renaming.patch
  a55a5e7-virt-aa-helper-log.patch
  e44bcae-virt-aa-helper-trailing-slash.patch
  bsc#936841
- Fixed crasher due to uninitialized values
  qemu-nbd-cleanup-fix.patch bsc#936841

OBS-URL: https://build.opensuse.org/request/show/315860
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=470
2015-07-10 12:21:25 +00:00

105 lines
4.0 KiB
Diff

From 24f3c2f7e0e196df5539616d03e039344768cd26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com>
Date: Thu, 25 Jun 2015 16:08:42 +0200
Subject: [PATCH 4/5] virt-aa-helper: add DomainGuest to mockup caps
With commit 3f9868a virt-aa-helper stopped working due to missing
DomainGuest in the caps.
The test with -c without arch also needs to be
removed since the new capabilities code uses the host arch when none is
provided.
---
src/security/virt-aa-helper.c | 25 ++++++++++++++++++++++++-
tests/virt-aa-helper-test | 3 ---
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 604fb93..4ce1e7a 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -73,6 +73,7 @@ typedef struct {
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 */
@@ -89,6 +90,7 @@ vahDeinit(vahControl * ctl)
virObjectUnref(ctl->caps);
virObjectUnref(ctl->xmlopt);
VIR_FREE(ctl->files);
+ VIR_FREE(ctl->virtType);
VIR_FREE(ctl->os);
VIR_FREE(ctl->newfile);
@@ -641,6 +643,7 @@ verify_xpath_context(xmlXPathContextPtr ctxt)
/*
* Parse the xml we received to fill in the following:
+ * ctl->virtType
* ctl->os
* ctl->arch
*
@@ -668,6 +671,11 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
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"));
@@ -694,7 +702,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
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 */
/*
@@ -730,6 +738,21 @@ get_definition(vahControl * ctl, const char *xmlStr)
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);
diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test
index 96471ff..caf2f97 100755
--- a/tests/virt-aa-helper-test
+++ b/tests/virt-aa-helper-test
@@ -194,9 +194,6 @@ testme "1" "-c with malformed xml" "-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>,,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"
--
2.1.4