[libvirt] [PATCH 4/5] qemu: hotplug: Add validation for coldplug of individual vcpus

Peter Krempa pkrempa at redhat.com
Tue Apr 4 07:14:44 UTC 2017


On Mon, Apr 03, 2017 at 18:24:59 -0400, John Ferlan wrote:
> 
> 
> On 03/31/2017 07:52 AM, Peter Krempa wrote:
> > Validate that users don't try to disable vcpu 0 and reject attempt to
> > modify a vcpu to the state it is currently in.
> > ---
> >  src/qemu/qemu_hotplug.c | 36 ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> > 
> > diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> > index 5488b1dd4..18a8df33a 100644
> > --- a/src/qemu/qemu_hotplug.c
> > +++ b/src/qemu/qemu_hotplug.c
> > @@ -5875,6 +5875,37 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
> >  }
> > 
> > 
> > +static int
> > +qemuDomainVcpuValidateConfig(virDomainDefPtr def,
> > +                             virBitmapPtr map,
> > +                             bool state)
> > +{
> > +    virDomainVcpuDefPtr vcpu;
> > +    ssize_t next = -1;
> > +
> > +    /* vcpu 0 can't be disabled */
> > +    if (!state && virBitmapIsBitSet(map, 0)) {
> > +        virReportError(VIR_ERR_INVALID_ARG, "%s",
> > +                       _("vCPU '0' must be enabled"));
> > +        return -1;
> > +    }
> > +
> > +    /* make sure that all selected vcpus are in the correct state */
> > +    while ((next = virBitmapNextSetBit(map, next)) >= 0) {
> > +        if (!(vcpu = virDomainDefGetVcpu(def, next)))
> > +            continue;
> > +
> > +        if (vcpu->online == state) {
> > +            virReportError(VIR_ERR_INVALID_ARG,
> > +                           _("vcpu '%zd' is already in requested state"), next);
> > +            return -1;
> > +        }
> 
> Does this really matter for this path? (config file). Wouldn't they just
> be changing to what they already have and is that really a big deal.

I used the same check as in the online path, but you are right, it does
not make much sense. I'll drop this check.

> IDC either way, but since there was no bz attached to this patch, I was
> just curious why the check.

Bugs are there even when nobody reports them :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170404/f3a58202/attachment-0001.sig>


More information about the libvir-list mailing list