On Wed, Aug 05, 2015 at 01:59:11PM +0200, Tomas Meszaros wrote:
Currently supports only renaming inactive domains without snapshots.
Signed-off-by: Tomas Meszaros <exo(a)tty.sk>
---
src/qemu/qemu_driver.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 172 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b9278f8..3ff04fe 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19835,6 +19835,177 @@ qemuDomainSetUserPassword(virDomainPtr dom,
}
+static int qemuDomainRename(virDomainPtr dom,
+ const char *new_name)
+ /* Change guest agent path. */
+ for (i = 0; i < vm->def->nchannels; i++) {
+ virDomainChrDefPtr channel = vm->def->channels[i];
+ if (channel->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
+ channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO
&&
+ channel->source.data.file.path &&
+ channel->target.name) {
+
+ if (virAsprintf(&new_guest_path, "%s/%s.%s",
+ cfg->channelTargetDir,
+ new_name, channel->target.name) < 0)
+ goto rollback;
+
+ old_guest_path = channel->source.data.file.path;
+ channel->source.data.file.path = new_guest_path;
+ new_guest_path = NULL;
+ agent = channel;
+ break;
+ }
+ }
IMHO, we should not touch this at all. It is making a (potentially
invalid) assumption about the way the socket paths are named. If
we go down this route of changing various aspects of device config,
then people will question why channels are special cased and not
renaming other things. It just will just end up as a mess of hard
coded policy which works for some cases and is wrong for others.
So I think we should just stick to changing the name of the VM
only and not touch any other aspect of XML config.
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|