Re: [PATCH 01/11] Convert Xen domain lookup driver methods to use virDomainDefPtr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 09, 2013 at 03:01:42PM +0200, Michal Privoznik wrote:
> On 09.05.2013 14:59, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> > 
> > Introduce use of a virDomainDefPtr in the domain lookup
> > APIs to simplify introduction of ACL security checks.
> > The virDomainPtr cannot be safely used, since the app
> > may have supplied mis-matching name/uuid/id fields. eg
> > the name points to domain X, while the uuid points to
> > domain Y. Resolving the virDomainPtr to a virDomainDefPtr
> > ensures a consistent name/uuid/id set.
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> > ---
> >  src/conf/domain_conf.c   |  24 ++++++++
> >  src/conf/domain_conf.h   |   4 ++
> >  src/libvirt_private.syms |   1 +
> >  src/xen/xen_driver.c     | 147 +++++++++++++++++++++++++++++++----------------
> >  src/xen/xen_hypervisor.c |  17 +++---
> >  src/xen/xen_hypervisor.h |   8 +--
> >  src/xen/xen_inotify.c    |  14 ++---
> >  src/xen/xend_internal.c  |  34 +++++------
> >  src/xen/xend_internal.h  |   4 +-
> >  src/xen/xm_internal.c    |  30 ++++------
> >  src/xen/xm_internal.h    |   5 +-
> >  11 files changed, 173 insertions(+), 115 deletions(-)
> > 
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index d55ce6b..61995cd 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -2048,6 +2048,30 @@ error:
> >      return NULL;
> >  }
> >  
> > +
> > +virDomainDefPtr virDomainDefNew(const char *name,
> > +                                const unsigned char *uuid,
> > +                                int id)
> > +{
> > +    virDomainDefPtr def;
> > +
> > +    if (VIR_ALLOC(def) < 0) {
> > +        virReportOOMError();
> > +        return NULL;
> > +    }
> > +
> > +    if (!(def->name = strdup(name))) {
> > +        VIR_FREE(def);
> > +        return NULL;
> > +    }
> 
> Can you switch to VIR_STRDUP instead?

Ok, consider this to be squashed in once acked

@@ -2060,7 +2060,7 @@ virDomainDefPtr virDomainDefNew(const char *name,
         return NULL;
     }
 
-    if (!(def->name = strdup(name))) {
+    if (VIR_STRDUP(def->name, name) < 0) {
         VIR_FREE(def);
         return NULL;
     }


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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]