3

I am using.

virsh -c qemu:///system edit VM-Name

And adding comments.

<!-- test comment here -->

It won't complain.* But the comment is removed.

*Usually if you make a syntax error (for example add an extra >) somewhere), it says something like this.

error: (domain_definition):75: Extra content at the end of the document
>
^
 Failed. Try again? [y,n,f,?]:

Is there any way to preserve comments in virsh / libvirt xml files?

2 Answers 2

3

It appears that now you can, copy your xml file somewhere, tell virsh to use it :

virsh define ~/vm.xml

and comment what you want.

When you launch the vm, virsh will make a copy of the file in /etc/libvirt, remove comments there and start the vm, thus not touching your original xml file /etc/libvirt.

0

Use:

<metadata comment="This is a comment"/>

Tested on CentOS 8 Stream with: virsh --version 4.5.0

1
  • This does not work on virsh 4.0.0
    – Dave
    Jun 1, 2022 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .