[libvirt] PATCH: Switch openvz driver to domain APIs

Daniel P. Berrange berrange at redhat.com
Fri Sep 5 14:40:14 UTC 2008


On Fri, Sep 05, 2008 at 04:31:06PM +0200, Jim Meyering wrote:
> "Daniel P. Berrange" <berrange at redhat.com> wrote:
> >> >  static int openvzDomainShutdown(virDomainPtr dom) {
> >> >      struct openvz_driver *driver = (struct openvz_driver *)dom->conn->privateData;
> >> > -    struct openvz_vm *vm = openvzFindVMByUUID(driver, dom->uuid);
> >> > -    const char *prog[] = {VZCTL, "--quiet", "stop", vm->vmdef->name, NULL};
> >> > +    virDomainObjPtr vm = virDomainFindByUUID(driver->domains, dom->uuid);
> >> > +    const char *prog[] = {VZCTL, "--quiet", "stop", vm->def->name, NULL};
> >>
> >> I know it's nothing new, but the above use of "vm" can dereference NULL.
> >
> > Every 'virDomainPtr' object is /required/ to have a non-NULL 'def' field.
> > Only the 'newDef' field is alllowed to be NULL.
> 
> Yes, but "vm" itself will be NULL if virDomainFindByUUID fails.

Oh, you meant the first pointer deference, not the second

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list