How can I modify the xml definition of a VM over ssh? I know that I can do this interactively by logging into the host and using:
virsh edit <domain name>
But I want to automate this modification of xml using a script that runs on a remote host and then executes commands over ssh on the KVM box.
From what I have observed is that virsh edit is opening the default editor (vi in my case) for me to edit the file. I want to somehow overwrite this file (which is interactively opened by virsh edit command) with vm definition contained in another text file.
I have found threads on how text can be piped to vi using:
cat <file name> | vi -
But that wont work in my case since,
- virsh is opening up default editor with arguments that I have no control over. (or at least I don't know how to modify those arguments)
- The default editor could be different on different KVM boxes.
Thanks in advance for helping out.
Edit: Just wanted to make clear that I do not have an option to power off the VM and redefine it. I want to modify a running domain.