Can't virsh edit a VM

I can’t seem to use the virsh command to edit the xml of my vm. Maybe I’m an idiot whos doing it wrong but when I type the command it says it can’t find vi.

Screenshot from 2021-01-21 12-46-00

Maybe try
vim /etc/libvirt/qemu/win10.xml
?
If not vim, try nano, if not, try another editor. It seems “virsh edit” cannot find vi editor, either because it is not installed, or because you don’t have an alias for vi to use vim.

EDITOR=vim, export it or set it in your ~/.bashrc

2 Likes

Unless you REALLY know what you are doing, don’t do this. Because virsh edit has syntax checking, so it will catch some issues. Kind of like visudo does.

Or optionally instead of vim, set whatever you normally use for command-line text editing.

Sorry, I sometimes forget people don’t backup their files before editing them. RIP.

This presumes one has a preference, rather than just following what ever copy and paste instructions any time one needs to make the magic pixies do what they should…

But I agree, should be able to change the editor to an app that is installed, like nano or whatever

Maybe like:

sudo EDITOR=nano virsh edit test

The real answer is to have all your config files in a git repository or other revision control.

Seems I forgot to specify an editor. I figured because I had nano installed it would default to it but I guess not.

2 Likes

There is a way to change the editor globally, but it virsh does not always seem to honour it.

It also seem virsh might ignore a named editor when called, depending on reports from the internet*

*the internet is often conflicted and wrong. Just like me :slight_smile:

1 Like