[libvirt] [PATCH 1/3] virsh: Two new helper functions for disk device changes
Eric Blake
eblake at redhat.com
Mon Feb 27 18:26:02 UTC 2012
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 at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120227/0c2caec0/attachment-0001.sig>
More information about the libvir-list
mailing list