[PATCH 1/6] domain: introduce constants for virVcpuInfo->cpu state values
Michal Privoznik
mprivozn at redhat.com
Thu Nov 12 13:46:45 UTC 2020
On 11/12/20 12:51 PM, Matt Coleman wrote:
> Signed-off-by: Matt Coleman <matt at datto.com>
> ---
> include/libvirt/libvirt-domain.h | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
> index b3310729bf..d52733190f 100644
> --- a/include/libvirt/libvirt-domain.h
> +++ b/include/libvirt/libvirt-domain.h
> @@ -1915,10 +1915,24 @@ struct _virVcpuInfo {
> unsigned int number; /* virtual CPU number */
> int state; /* value from virVcpuState */
> unsigned long long cpuTime; /* CPU time used, in nanoseconds */
> - int cpu; /* real CPU number, or -1 if offline */
> + int cpu; /* real CPU number, or one of the VIR_VCPU_INFO_CPU_* constants */
> };
> typedef virVcpuInfo *virVcpuInfoPtr;
>
> +/**
> + * VIR_VCPU_INFO_CPU_OFFLINE:
> + *
> + * The VCPU is offline.
> + */
> +# define VIR_VCPU_INFO_CPU_OFFLINE -1
> +
> +/**
> + * VIR_VCPU_INFO_CPU_UNAVAILABLE:
> + *
> + * The hypervisor does not expose real CPU information for VCPUs.
> + */
> +# define VIR_VCPU_INFO_CPU_UNAVAILABLE -2
> +
> /* Flags for controlling virtual CPU hot-plugging. */
> typedef enum {
> /* See virDomainModificationImpact for these flags. */
>
How about making this an enum instead?
diff --git c/include/libvirt/libvirt-domain.h
w/include/libvirt/libvirt-domain.h
index b3310729bf..a12a8e6625 100644
--- c/include/libvirt/libvirt-domain.h
+++ w/include/libvirt/libvirt-domain.h
@@ -1910,12 +1910,19 @@ typedef enum {
# endif
} virVcpuState;
+
+typedef enum {
+ VIR_VCPU_INFO_CPU_OFFLINE = -1, /* the vCPU is offline */
+ VIR_VCPU_INFO_CPU_UNAVAILABLE = -2, /* the hypervisor does not
expose real
+ CPU information for vCPUs. */
+} virVcpuHostCpuState;
+
typedef struct _virVcpuInfo virVcpuInfo;
struct _virVcpuInfo {
unsigned int number; /* virtual CPU number */
int state; /* value from virVcpuState */
unsigned long long cpuTime; /* CPU time used, in nanoseconds */
- int cpu; /* real CPU number, or -1 if offline */
+ int cpu; /* real CPU number, or one of the
virVcpuHostCpuState */
};
typedef virVcpuInfo *virVcpuInfoPtr;
Michal
More information about the libvir-list
mailing list