[Libvir] [PATCH] Implement SetVcpus and DomainGetMaxVcpus for qemu

Daniel P. Berrange berrange at redhat.com
Mon Apr 28 18:39:29 UTC 2008


On Mon, Apr 28, 2008 at 01:46:28PM -0400, Cole Robinson wrote:
> The attached patch fills in two of the vcpu functions for the qemu driver:
> 
> virDomainSetVcpus : set the number of vcpus the domain can use
> virDomainGetMaxVcpus : max number of vcpus that can be assigned to the domain.
> 
> Code change is only in qemu_driver, as the backend stuff was already in place.
> I also edited qemudGetMaxVcpus to ignore case when checking the passed OS
> type, since it wasn't matching the returned results of qemudDomainGetOSType.
> 
> Thanks,
> Cole

> diff --git a/src/qemu_driver.c b/src/qemu_driver.c
> index b65ae66..8bedf5a 100644
> --- a/src/qemu_driver.c
> +++ b/src/qemu_driver.c
> @@ -113,6 +113,8 @@ static int qemudShutdownNetworkDaemon(virConnectPtr conn,
>                                        struct qemud_driver *driver,
>                                        struct qemud_network *network);
>  
> +static int qemudDomainGetMaxVcpus(virDomainPtr dom);
> +
>  static struct qemud_driver *qemu_driver = NULL;
>  
>  
> @@ -1524,21 +1526,23 @@ static const char *qemudGetType(virConnectPtr conn ATTRIBUTE_UNUSED) {
>      return "QEMU";
>  }
>  
> -static int qemudGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                            const char *type) {
> +static int qemudGetMaxVCPUs(virConnectPtr conn, const char *type) {
>      if (!type)
>          return 16;
>  
> -    if (!strcmp(type, "qemu"))
> +    if (!strcasecmp(type, "qemu"))
>          return 16;
>  
>      /* XXX future KVM will support SMP. Need to probe
>         kernel to figure out KVM module version i guess */
> -    if (!strcmp(type, "kvm"))
> +    if (!strcasecmp(type, "kvm"))
>          return 1;

This comment is seriously out of date - KVM supports 16 (or was is 32?) vCPUs,
so we should change this.


Aside from that, this looks OK to me.

Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list