Re: [PATCH 1/3] virsh: Two new helper functions for disk device changes

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

 



On 02/27/2012 05:11 AM, Osier Yang wrote:
> vshFindDisk is to find the disk node in xml doc with given source
> path or target of disk device, and type (indicates disk type,
> normal disk or changeable disk).
> 
> vshPrepareDiskXML is to make changes on the disk node (e.g. create
> and insert the new <source> node for inserting media of CDROM drive).
> 
> They are marked as unused temporarily.
> ---
>  tools/virsh.c |  215 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 215 insertions(+), 0 deletions(-)
> 

> +    if (STREQ_NULLABLE(device_type, "cdrom") ||
> +        STREQ_NULLABLE(device_type, "floppy")) {
> +        bool has_source = false;
> +        disk_type = virXMLPropString(disk_node, "type");
> +
> +        cur = disk_node->children;
> +        while (cur != NULL) {
> +            if (cur->type == XML_ELEMENT_NODE &&
> +                xmlStrEqual(cur->name, BAD_CAST "source")) {
> +                has_source = true;
> +                break;
> +            }
> +            cur = cur->next;
> +        }
> +
> +        if (!has_source) {
> +            if (type == VSH_PREPARE_DISK_XML_EJECT) {
> +                vshError(NULL, _("The disk device whose source path or target "
> +                                 "is '%s' doesn't have media"), path);

If there is no source, then the disk device was found via target, not
source path :)  Avoid the problem, as well as making things shorter, by
changing the error message to:

"The disk device '%s' doesn't have media"

> +
> +        if (has_source) {
> +            if (type == VSH_PREPARE_DISK_XML_INSERT) {
> +                vshError(NULL, _("The disk device whose source path or target "
> +                                 "is '%s' already has media"), path);

Along those lines, a consistent error message would be:

"The disk device '%s' already has media"

ACK with those nits fixed.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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