Re: [libvirt] [PATCH] repeat lookup by name in LookupByID

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

 



On Wed, Jul 16, 2008 at 12:04:39PM +0400, Evgeniy Sokolov wrote:
> There was error every time when I undefine stoped container
> "no domain with matching id".
> Bug arrise due to stoped container has ID = -1.

This is not an error - this is intentional. There is no meaningful
ID for an inactive domain, thus lookupByID is intended to fail.

> In such case container will be searched by name.

No, this is wrong. The application should use lookupByName instead.

> 
> other:
> use VIR_ERR_NO_DOMAIN when domain is not found

> Index: src/openvz_driver.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/openvz_driver.c,v
> retrieving revision 1.28
> diff -u -p -r1.28 openvz_driver.c
> --- src/openvz_driver.c	11 Jul 2008 11:09:44 -0000	1.28
> +++ src/openvz_driver.c	16 Jul 2008 07:51:19 -0000
> @@ -128,11 +128,22 @@ static void cmdExecFree(char *cmdExec[])
>  static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
>                                     int id) {
>      struct openvz_driver *driver = (struct openvz_driver *)conn->privateData;
> -    struct openvz_vm *vm = openvzFindVMByID(driver, id);
> +    struct openvz_vm *vm;
>      virDomainPtr dom;
>  
> +    vm = openvzFindVMByID(driver, id);
> +
> +    if (!vm) { /*try to find by name*/
> +        char name[OPENVZ_NAME_MAX];
> +        if (snprintf(name, OPENVZ_NAME_MAX, "%d",id) >= OPENVZ_NAME_MAX) {
> +            openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Too long domain name"));
> +            return NULL;
> +        }
> +        vm = openvzFindVMByName(driver, name);
> +    }

This souldn't be applied.

> +
>      if (!vm) {
> -        openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("no domain with matching id"));
> +        openvzError(conn, VIR_ERR_NO_DOMAIN, NULL);

This and the other error code changes are fine.

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

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