[libvirt] [PATCH] Device{Attach,Detach}: Document S4 limitations

https://bugzilla.redhat.com/show_bug.cgi?id=808463 Well, libvirt doesn't distinguish between domain poweroff and hibernation (S4). It's hard to differentiate these two on a real machine anyway. As a result, any device that is hot(un-)plugged is lost (appears again) when domain is started again as from our POV it is a fresh cold boot. Instead of doing anything wise here, we should just document this as known limitation. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libvirt.c b/src/libvirt.c index b6c99c5..20297eb 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -10319,6 +10319,9 @@ virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) * in an existing CDROM/Floppy device, however, applications are * recommended to use the virDomainUpdateDeviceFlag method instead. * + * Be aware that a device that is hotplugged may disappear if + * domain resumes from the S4 state (also known as hibernation). + * * Returns 0 in case of success, -1 in case of failure. */ int @@ -10374,6 +10377,9 @@ virDomainAttachDevice(virDomainPtr domain, const char *xml) * in an existing CDROM/Floppy device, however, applications are * recommended to use the virDomainUpdateDeviceFlag method instead. * + * Be aware that a device that is hotplugged may disappear if + * domain resumes from the S4 state (also known as hibernation). + * * Returns 0 in case of success, -1 in case of failure. */ int @@ -10416,6 +10422,9 @@ virDomainAttachDeviceFlags(virDomainPtr domain, * Destroy a virtual device attachment to backend. This function, * having hot-unplug semantics, is only allowed on an active domain. * + * Be aware that a device that was unplugged may appear again + * if domain resumes from the S4 state (also known as hibernation). + * * Returns 0 in case of success, -1 in case of failure. */ int @@ -10487,6 +10496,9 @@ virDomainDetachDevice(virDomainPtr domain, const char *xml) * a synchronous removal. In other words, this API may wait a bit for the * removal to complete in case it was not synchronous. * + * Be aware that a device that was unplugged may appear again + * if domain resumes from the S4 state (also known as hibernation). + * * Returns 0 in case of success, -1 in case of failure. */ int -- 1.9.0

On 04/30/2014 07:55 AM, Michal Privoznik wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=808463
Well, libvirt doesn't distinguish between domain poweroff and hibernation (S4). It's hard to differentiate these two on a real machine anyway. As a result, any device that is hot(un-)plugged is lost (appears again) when domain is started again as from our POV it is a fresh cold boot. Instead of doing anything wise here, we should just document this as known limitation.
Umm, doesn't qemu give us a different event when a guest stops due to S4 than when it stops due to power off? Yeah, we don't do a good job of tracking that a guest is in S4 (since the qemu process no longer exists), but that's something that could be improved.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/src/libvirt.c b/src/libvirt.c index b6c99c5..20297eb 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -10319,6 +10319,9 @@ virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) * in an existing CDROM/Floppy device, however, applications are * recommended to use the virDomainUpdateDeviceFlag method instead. * + * Be aware that a device that is hotplugged may disappear if + * domain resumes from the S4 state (also known as hibernation).
Maybe be a bit more positive: Be aware that hotplug changes might not persist across a domain going into S4 state (also known as hibernation) unless you also modify the persistent domain definition. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 30.04.2014 17:46, Eric Blake wrote:
On 04/30/2014 07:55 AM, Michal Privoznik wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=808463
Well, libvirt doesn't distinguish between domain poweroff and hibernation (S4). It's hard to differentiate these two on a real machine anyway. As a result, any device that is hot(un-)plugged is lost (appears again) when domain is started again as from our POV it is a fresh cold boot. Instead of doing anything wise here, we should just document this as known limitation.
Umm, doesn't qemu give us a different event when a guest stops due to S4 than when it stops due to power off? Yeah, we don't do a good job of tracking that a guest is in S4 (since the qemu process no longer exists), but that's something that could be improved.
Well, there are some cases where S4 is distinguishable to bare halt. But it all depends on the guest kernel playing nicely. I mean, for instance take the Linux kernel. If S4 is supported in the ACPI, the it correctly sets the S4 in ACPI registers. But if it's not supported in the ACPI, then you can still do S4 but you won't be notified about it (can't tell out of the box if guest did S4 or halt). And I recall something similar with the Windows kernel.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/src/libvirt.c b/src/libvirt.c index b6c99c5..20297eb 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -10319,6 +10319,9 @@ virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) * in an existing CDROM/Floppy device, however, applications are * recommended to use the virDomainUpdateDeviceFlag method instead. * + * Be aware that a device that is hotplugged may disappear if + * domain resumes from the S4 state (also known as hibernation).
Maybe be a bit more positive:
Be aware that hotplug changes might not persist across a domain going into S4 state (also known as hibernation) unless you also modify the persistent domain definition.
Okay, that sounds better. Do you want me to repost?

On 04/30/2014 09:52 AM, Michal Privoznik wrote:
On 30.04.2014 17:46, Eric Blake wrote:
On 04/30/2014 07:55 AM, Michal Privoznik wrote:
Maybe be a bit more positive:
Be aware that hotplug changes might not persist across a domain going into S4 state (also known as hibernation) unless you also modify the persistent domain definition.
Okay, that sounds better. Do you want me to repost?
Sure, just to make sure it still reads well to a native speaker. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Michal Privoznik