From: Michael Kelley <mikelley@microsoft.com>
To: Dexuan Cui <decui@microsoft.com>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
vkuznets <vkuznets@redhat.com>,
"marcelo.cerri@canonical.com" <marcelo.cerri@canonical.com>
Subject: RE: [PATCH] Drivers: hv: vmbus: Add /sys/bus/vmbus/supported_features
Date: Wed, 6 Jan 2021 17:37:38 +0000 [thread overview]
Message-ID: <MWHPR21MB15934AF3CA6C91DB036F7970D7D09@MWHPR21MB1593.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20201223001222.30242-1-decui@microsoft.com>
From: Dexuan Cui <decui@microsoft.com> Sent: Tuesday, December 22, 2020 4:12 PM
>
> When a Linux VM runs on Hyper-V, if the host toolstack doesn't support
> hibernation for the VM (this happens on old Hyper-V hosts like Windows
> Server 2016, or new Hyper-V hosts if the admin or user doesn't declare
> the hibernation intent for the VM), the VM is discouraged from trying
> hibernation (because the host doesn't guarantee that the VM's virtual
> hardware configuration will remain exactly the same across hibernation),
> i.e. the VM should not try to set up the swap partition/file for
> hibernation, etc.
>
> x86 Hyper-V uses the presence of the virtual ACPI S4 state as the
> indication of the host toolstack support for a VM. Currently there is
> no easy and reliable way for the userspace to detect the presence of
> the state (see https://lkml.org/lkml/2020/12/11/1097). Add
> /sys/bus/vmbus/supported_features for this purpose.
I'm OK with surfacing the hibernation capability via an entry in
/sys/bus/vmbus. Correct me if I'm wrong, but I think the concept
being surfaced is not "ACPI S4 state" precisely, but slightly more
generally whether hibernation is supported for the VM. While
those two concepts may be 1:1 for the moment, there might be
future configurations where "hibernation is supported" depends
on other factors as well.
The guidance for things in /sys is that they generally should
be single valued (see Documentation/filesystems/sysfs.rst). So my
recommendation is to create a "hibernation" entry that has a value
of 0 or 1. That's the pattern I see in lots of other places in /sys. If
other Hyper-V or VMbus-related features need to be surfaced in
the future, they would have their own single-valued entry.
Michael
>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> ---
> Documentation/ABI/stable/sysfs-bus-vmbus | 7 +++++++
> drivers/hv/vmbus_drv.c | 20 ++++++++++++++++++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/Documentation/ABI/stable/sysfs-bus-vmbus
> b/Documentation/ABI/stable/sysfs-bus-vmbus
> index c27b7b89477c..3ba765ae6695 100644
> --- a/Documentation/ABI/stable/sysfs-bus-vmbus
> +++ b/Documentation/ABI/stable/sysfs-bus-vmbus
> @@ -1,3 +1,10 @@
> +What: /sys/bus/vmbus/supported_features
> +Date: Dec 2020
> +KernelVersion: 5.11
> +Contact: Dexuan Cui <decui@microsoft.com>
> +Description: Features specific to VMs running on Hyper-V
> +Users: Daemon that sets up swap partition/file for hibernation
> +
> What: /sys/bus/vmbus/devices/<UUID>/id
> Date: Jul 2009
> KernelVersion: 2.6.31
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index d491fdcee61f..958487a40a18 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -678,6 +678,25 @@ static const struct attribute_group vmbus_dev_group = {
> };
> __ATTRIBUTE_GROUPS(vmbus_dev);
>
> +/* Set up bus attribute(s) for /sys/bus/vmbus/supported_features */
> +static ssize_t supported_features_show(struct bus_type *bus, char *buf)
> +{
> + bool hb = hv_is_hibernation_supported();
> +
> + return sprintf(buf, "%s\n", hb ? "hibernation" : "");
> +}
> +
> +static BUS_ATTR_RO(supported_features);
> +
> +static struct attribute *vmbus_bus_attrs[] = {
> + &bus_attr_supported_features.attr,
> + NULL,
> +};
> +static const struct attribute_group vmbus_bus_group = {
> + .attrs = vmbus_bus_attrs,
> +};
> +__ATTRIBUTE_GROUPS(vmbus_bus);
> +
> /*
> * vmbus_uevent - add uevent for our device
> *
> @@ -1024,6 +1043,7 @@ static struct bus_type hv_bus = {
> .uevent = vmbus_uevent,
> .dev_groups = vmbus_dev_groups,
> .drv_groups = vmbus_drv_groups,
> + .bus_groups = vmbus_bus_groups,
> .pm = &vmbus_pm,
> };
>
> --
> 2.19.1
next prev parent reply other threads:[~2021-01-06 17:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 0:12 [PATCH] Drivers: hv: vmbus: Add /sys/bus/vmbus/supported_features Dexuan Cui
2021-01-05 12:58 ` Wei Liu
2021-01-05 23:04 ` Dexuan Cui
2021-01-06 16:23 ` Wei Liu
2021-01-06 20:48 ` Dexuan Cui
2021-01-06 17:37 ` Michael Kelley [this message]
2021-01-06 20:49 ` Dexuan Cui
2021-01-07 12:46 ` Boqun Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MWHPR21MB15934AF3CA6C91DB036F7970D7D09@MWHPR21MB1593.namprd21.prod.outlook.com \
--to=mikelley@microsoft.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=sthemmin@microsoft.com \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).