[libvirt] [PATCH 03/23] Add support for <hostdev mode="capabilities">

Daniel P. Berrange berrange at redhat.com
Mon Dec 17 12:48:24 UTC 2012


On Fri, Dec 14, 2012 at 06:37:41PM +0800, Osier Yang wrote:
> On 2012年12月01日 04:26, Daniel P. Berrange wrote:
> >diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
> >index 939d213..e61eabe 100644
> >--- a/src/conf/domain_audit.c
> >+++ b/src/conf/domain_audit.c
> >@@ -260,42 +260,72 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
> >  void virDomainHostdevDefFree(virDomainHostdevDefPtr def)
> >@@ -3026,6 +3041,71 @@ error:
> >      return ret;
> >  }
> >
> >+static int
> >+virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
> >+                                xmlXPathContextPtr ctxt,
> >+                                const char *type,
> >+                                virDomainHostdevDefPtr def)
> >+{
> >+    xmlNodePtr sourcenode;
> >+    int ret = -1;
> >+
> >+    /* @type is passed in from the caller rather than read from the
> >+     * xml document, because it is specified in different places for
> >+     * different kinds of defs - it is an attribute of
> >+     *<source>/<address>  for an intelligent hostdev (<interface>),
> >+     * but an attribute of the toplevel element for a standard
> >+     *<hostdev>.  (the functions we're going to call expect address
> >+     * type to already be known).
> 
> Per the @type is passed in from caller...

Correct, but the caller gets that value from the XML which
may result in NULL being passed

> 
> >+     */
> >+    if (type) {
> >+        if ((def->source.caps.type
> >+             = virDomainHostdevCapsTypeFromString(type))<  0) {
> >+            virReportError(VIR_ERR_XML_ERROR,
> >+                           _("unknown host device source address type '%s'"),
> >+                           type);
> >+            goto error;
> >+        }
> >+    } else {
> >+        virReportError(VIR_ERR_XML_ERROR,
> >+                       "%s", _("missing source address type"));
> >+        goto error;
> >+    }
> 
> But this indicates a parsing error.

So this check is correct.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list