From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH v6 7/9] xl: enable getting and setting soft Date: Wed, 28 May 2014 17:01:25 +0100 Message-ID: <1401292885.7504.48.camel@Abyss> References: <1401237770-7003-1-git-send-email-dario.faggioli@citrix.com> <1401237770-7003-8-git-send-email-dario.faggioli@citrix.com> <1401291227.10916.38.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0148212546777717240==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WpgIT-0007Us-KB for xen-devel@lists.xenproject.org; Wed, 28 May 2014 16:01:45 +0000 In-Reply-To: <1401291227.10916.38.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: KeirFraser , George Dunlap , AndrewCooper , Ian Jackson , Jan Beulich , xen-devel List-Id: xen-devel@lists.xenproject.org --===============0148212546777717240== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-KEdSHw6XBuk8iLcfAuYn" --=-KEdSHw6XBuk8iLcfAuYn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2014-05-28 at 16:33 +0100, Ian Campbell wrote: > On Wed, 2014-05-28 at 01:42 +0100, Dario Faggioli wrote: > > @@ -4653,17 +4656,32 @@ int main_vcpulist(int argc, char **argv) > > return 0; > > } > > =20 > > -static int vcpupin(uint32_t domid, const char *vcpu, char *cpu) > > +int main_vcpupin(int argc, char **argv) > > { > > libxl_vcpuinfo *vcpuinfo; > > - libxl_bitmap cpumap; > > - > > - uint32_t vcpuid; > > + libxl_bitmap cpumap, cpumap_soft;; > > + uint32_t vcpuid, domid; > > + const char *vcpu; > > char *endptr; > > - int i, nb_cpu, nb_vcpu, rc =3D -1; > > + int opt, nb_cpu, nb_vcpu, rc =3D -1; > > + libxl_bitmap *soft =3D &cpumap_soft, *hard =3D &cpumap; > > + static struct option opts[] =3D { > > + {"soft", 0, 0, 's'}, >=20 > I think this is a remnant of a previous iteration? >=20 Gah! Sorry for this. I looked at the whole series looking for remnant a few times, but I guess it's true that we're blind wrt our own code! > > - if (vcpupin_parse(cpu, &cpumap)) > > + /* > > + * Syntax is: xl vcpu-pin > > + * We want to handle all the following cases ('-' means > > + * "leave it alone"): > > + * xl vcpu-pin 0 3 3,4 > > + * xl vcpu-pin 0 3 3,4 - > > + * xl vcpu-pin 0 3 - 6-9 > > + * xl vcpu-pin 0 3 3,4 6-9 > > + */ > > + if (argc <=3D 4 || (argc =3D=3D 5 && !strcmp(argv[optind+3], "-"))= ) >=20 > You are mixing raw argc values and offsets from optind here, which is a > bit confusing. >=20 > It would be valid to do > argc -=3D optind; > argv +=3D optind; > optind =3D 0; > and then use argv[0] ...[1] etc. >=20 I agree it's confusing, and I like this solution above, I'll go for it. > > + soft =3D NULL; > > + if (argc =3D=3D 5 && !strcmp(argv[optind+2], "-")) > > + hard =3D NULL; > > + > > + if (hard && vcpupin_parse(argv[optind+2], &cpumap)) > > + goto out; > > + if (soft && vcpupin_parse(argv[optind+3], &cpumap_soft)) > > goto out; >=20 > You've just parsed argv[option+2] and [...+3] into hard and soft > respectively. >=20 > Might some of this be simplified by making vcpupin_parse accept NULL > and/or making it handle "-"? e.g.=20 > hard =3D argv[opting+2] > soft =3D argc > XXX > argc[optind+3] : NULL > vcpupin_parse(&hard, &cpumap); > vcpupin_parse(&soft, &cpumap); >=20 > (sets hard/soft =3D=3D NULL on input of "-", returns silently on hard/sof= t > =3D=3D NULL. >=20 I think this will make it simpler. I'll give it a try. > > diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c > > index 4279b9f..d03c52a 100644 > > --- a/tools/libxl/xl_cmdtable.c > > +++ b/tools/libxl/xl_cmdtable.c > > @@ -218,7 +218,7 @@ struct cmd_spec cmd_table[] =3D { > > { "vcpu-pin", > > &main_vcpupin, 1, 1, > > "Set which CPUs a VCPU can use", > > - " ", > > + " =20 > Missing a closing > >=20 Ok. > Also, I think "-" is a valid alternative now, right? >=20 Yes it is. Thanks and Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-KEdSHw6XBuk8iLcfAuYn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iEYEABECAAYFAlOGCFUACgkQk4XaBE3IOsRyQgCcD+8nKlBw1hx5IPFcqTr2IVF4 wmAAoJG+mRs4LFVAkKcNbs1ZuQ3tUiYg =axl6 -----END PGP SIGNATURE----- --=-KEdSHw6XBuk8iLcfAuYn-- --===============0148212546777717240== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============0148212546777717240==--