This makes a backwards-compatible change to the add-domain API. If
the optional allowuuid flag is true then UUIDs can be used instead of
names in the domain name parameter.
This returns the internal QEMU command line. 'debug' commands are
not part of the formal API and can be removed or changed at any time.");
This returns the internal QEMU command line. 'debug' commands are
not part of the formal API and can be removed or changed at any time.");
- ("add_domain", (RInt "nrdisks", [String "dom"], [String "libvirturi"; Bool "readonly"; String "iface"; Bool "live"]), -1, [FishAlias "domain"],
+ ("add_domain", (RInt "nrdisks", [String "dom"], [String "libvirturi"; Bool "readonly"; String "iface"; Bool "live"; Bool "allowuuid"]), -1, [FishAlias "domain"],
[],
"add the disk(s) from a named libvirt domain",
"\
[],
"add the disk(s) from a named libvirt domain",
"\
to try. See L<guestfs(3)/ATTACHING TO RUNNING DAEMONS> for more
information.
to try. See L<guestfs(3)/ATTACHING TO RUNNING DAEMONS> for more
information.
+If the C<allowuuid> flag is true (default is false) then a UUID
+I<may> be passed instead of the domain name. The C<dom> string is
+treated as a UUID first and looked up, and if that lookup fails
+then we treat C<dom> as a name as usual.
+
The other optional parameters are passed directly through to
C<guestfs_add_drive_opts>.");
The other optional parameters are passed directly through to
C<guestfs_add_drive_opts>.");
const char *libvirturi;
int readonly;
int live;
const char *libvirturi;
int readonly;
int live;
const char *iface;
struct guestfs___add_libvirt_dom_argv optargs2 = { .bitmask = 0 };
const char *iface;
struct guestfs___add_libvirt_dom_argv optargs2 = { .bitmask = 0 };
? optargs->iface : NULL;
live = optargs->bitmask & GUESTFS_ADD_DOMAIN_LIVE_BITMASK
? optargs->live : 0;
? optargs->iface : NULL;
live = optargs->bitmask & GUESTFS_ADD_DOMAIN_LIVE_BITMASK
? optargs->live : 0;
+ allowuuid = optargs->bitmask & GUESTFS_ADD_DOMAIN_ALLOWUUID_BITMASK
+ ? optargs->allowuuid : 0;
if (live && readonly) {
error (g, _("you cannot set both live and readonly flags"));
if (live && readonly) {
error (g, _("you cannot set both live and readonly flags"));
*/
virConnSetErrorFunc (conn, NULL, ignore_errors);
*/
virConnSetErrorFunc (conn, NULL, ignore_errors);
- dom = virDomainLookupByName (conn, domain_name);
+ /* Try UUID first. */
+ if (allowuuid)
+ dom = virDomainLookupByUUIDString (conn, domain_name);
+
+ /* Try ordinary domain name. */
+ if (!dom)
+ dom = virDomainLookupByName (conn, domain_name);
+
if (!dom) {
err = virGetLastError ();
error (g, _("no libvirt domain called '%s': %s"),
if (!dom) {
err = virGetLastError ();
error (g, _("no libvirt domain called '%s': %s"),