Re: [libvirt] [PATCH] provide the object name on lookup error

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

 



On Tue, Jul 07, 2009 at 05:52:03PM +0200, Daniel Veillard wrote:
>   There were a number of places where the object name was not not
> reported, based on the use I don't think the string could be NULL
> in any of those. I also fixed a few POOL error which were really
> VOLume ones.

There's a few places here still using VIR_ERR_INVALID_xxxxx which
could also be changed to VIR_ERR_NO_xxxx, since the INVALID errors
codes description is refering to bad pointer addresses.

Aside from that, this looks good.

Regards,
Daniel


> diff --git a/src/network_driver.c b/src/network_driver.c
> index c5c4c2d..9621782 100644
> --- a/src/network_driver.c
> +++ b/src/network_driver.c
> @@ -971,7 +971,7 @@ static virNetworkPtr networkLookupByName(virConnectPtr conn,
>      networkDriverUnlock(driver);
>      if (!network) {
>          networkReportError(conn, NULL, NULL, VIR_ERR_NO_NETWORK,
> -                         "%s", _("no network with matching name"));
> +                         _("no network with matching name '%s'"), name);
>          goto cleanup;
>      }
>  
> diff --git a/src/node_device.c b/src/node_device.c
> index e0aaefc..74e7a4f 100644
> --- a/src/node_device.c
> +++ b/src/node_device.c
> @@ -280,7 +280,8 @@ static char *nodeDeviceDumpXML(virNodeDevicePtr dev,
>  
>      if (!obj) {
>          virNodeDeviceReportError(dev->conn, VIR_ERR_INVALID_NODE_DEVICE,
> -                              "%s", _("no node device with matching name"));
> +                                _("no node device with matching name '%s'"),
> +                                 dev->name);
>          goto cleanup;
>      }
>  
> @@ -308,7 +309,8 @@ static char *nodeDeviceGetParent(virNodeDevicePtr dev)
>  
>      if (!obj) {
>          virNodeDeviceReportError(dev->conn, VIR_ERR_INVALID_NODE_DEVICE,
> -                              "%s", _("no node device with matching name"));
> +                                _("no node device with matching name '%s'"),
> +                                 dev->name);
>          goto cleanup;
>      }
>  
> @@ -342,7 +344,8 @@ static int nodeDeviceNumOfCaps(virNodeDevicePtr dev)
>  
>      if (!obj) {
>          virNodeDeviceReportError(dev->conn, VIR_ERR_INVALID_NODE_DEVICE,
> -                              "%s", _("no node device with matching name"));
> +                                _("no node device with matching name '%s'"),
> +                                 dev->name);
>          goto cleanup;
>      }
>  
> @@ -372,7 +375,8 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
>  
>      if (!obj) {
>          virNodeDeviceReportError(dev->conn, VIR_ERR_INVALID_NODE_DEVICE,
> -                              "%s", _("no node device with matching name"));
> +                                _("no node device with matching name '%s'"),
> +                                 dev->name);
>          goto cleanup;
>      }
>  
> diff --git a/src/storage_driver.c b/src/storage_driver.c
> index 5a26993..49e2c84 100644
> --- a/src/storage_driver.c
> +++ b/src/storage_driver.c
> @@ -295,7 +295,7 @@ storagePoolLookupByName(virConnectPtr conn,
>  
>      if (!pool) {
>          virStorageReportError(conn, VIR_ERR_NO_STORAGE_POOL,
> -                              "%s", _("no pool with matching name"));
> +                              _("no pool with matching name '%s'"), name);
>          goto cleanup;
>      }
>  
> @@ -1099,8 +1099,9 @@ storageVolumeLookupByName(virStoragePoolPtr obj,
>      vol = virStorageVolDefFindByName(pool, name);
>  
>      if (!vol) {
> -        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
> -                              "%s", _("no storage vol with matching name"));
> +        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_VOL,
> +                             _("no storage vol with matching name '%s'"),
> +                              name);
>          goto cleanup;
>      }
>  
> @@ -1340,7 +1341,8 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj,
>  
>      if (diffpool && !origpool) {
>          virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
> -                              "%s", _("no storage pool with matching name"));
> +                             _("no storage pool with matching name '%s'"),
> +                              vobj->pool);
>          goto cleanup;
>      }
>  
> @@ -1361,8 +1363,9 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj,
>  
>      origvol = virStorageVolDefFindByName(origpool, vobj->name);
>      if (!origvol) {
> -        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
> -                              "%s", _("no storage vol with matching name"));
> +        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_VOL,
> +                             _("no storage vol with matching name '%s'"),
> +                              vobj->name);
>          goto cleanup;
>      }
>  
> @@ -1501,8 +1504,9 @@ storageVolumeDelete(virStorageVolPtr obj,
>      vol = virStorageVolDefFindByName(pool, obj->name);
>  
>      if (!vol) {
> -        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
> -                              "%s", _("no storage vol with matching name"));
> +        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_VOL,
> +                             _("no storage vol with matching name '%s'"),
> +                              obj->name);
>          goto cleanup;
>      }
>  
> @@ -1576,8 +1580,9 @@ storageVolumeGetInfo(virStorageVolPtr obj,
>      vol = virStorageVolDefFindByName(pool, obj->name);
>  
>      if (!vol) {
> -        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
> -                              "%s", _("no storage vol with matching name"));
> +        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_VOL,
> +                             _("no storage vol with matching name '%s'"),
> +                              obj->name);
>          goto cleanup;
>      }
>  
> @@ -1628,8 +1633,9 @@ storageVolumeGetXMLDesc(virStorageVolPtr obj,
>      vol = virStorageVolDefFindByName(pool, obj->name);
>  
>      if (!vol) {
> -        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
> -                              "%s", _("no storage vol with matching name"));
> +        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_VOL,
> +                             _("no storage vol with matching name '%s'"),
> +                              obj->name);
>          goto cleanup;
>      }
>  
> @@ -1674,8 +1680,9 @@ storageVolumeGetPath(virStorageVolPtr obj) {
>      vol = virStorageVolDefFindByName(pool, obj->name);
>  
>      if (!vol) {
> -        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
> -                              "%s", _("no storage vol with matching name"));
> +        virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_VOL,
> +                             _("no storage vol with matching name '%s'"),
> +                              obj->name);
>          goto cleanup;
>      }
>  

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


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