6

I wish to set the virtualized hardware time to a fixed value upon bootup. In Qemu, this is easy:

qemu-kvm \
    -rtc base=2011-11-11T11:11:00 \
    …

However I fail to see a way of adding this to a guest configuration in libvirt (v2.2.0). Some of the parameters of Qemu appear to be supported, but it would appear that date is not among them. Is there another way?

1 Answer 1

6

Turns out libvirt supports direct passing of command line arguments to the Qemu backend. In order to “unlock” this functionality, one needs to include the relevant namespace in the guest definition:

-<domain type='kvm'>
+<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>

Now one has access to the tag commandline. Inside it, arguments are specified using a series of arg elements:

<qemu:commandline>
  <qemu:arg value='-rtc'/>
  <qemu:arg value='base=2011-11-11T11:11:00'/>
</qemu:commandline>

That end up being appended to Qemu’s argv[].

1
  • It requires the guest in poweroff state and systemctl restart libvirtd.service
    – rfmoz
    Commented Dec 10, 2023 at 0:42

You must log in to answer this question.

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