Re: [libvirt] [PATCH] Remove phyp driver
On 20/12/2019 - 12:26:52, Cole Robinson wrote: > On 12/18/19 2:50 PM, Michal Prívozník wrote: > > [I'm CCing Eduardo, who worked a lot on this driver in the past. Maybe > > he knows if this hypervisor is still alive.] > > > > On 12/18/19 4:43 PM, Cole Robinson wrote: > >> The phyp driver was added in 2009 and does not appear to have had any > >> real feature change since 2011. There's virtually no evidence online > >> of users actually using it. IMO it's time to kill it. I was super sure I had replied this before, but looks like I didn't :) I'm not really aware of the usage of this code. I guess it's not being used at all nowadays? I really can't tell. But if you're waiting for my ACK to drop all this: ACK > >> > >> Signed-off-by: Cole Robinson > >> --- > >> I raised this in 3.5 years ago: > >> https://www.redhat.com/archives/libvir-list/2016-April/msg01060.html > >> > >> Not much on phyp/ side has changed since then, except dozens of dev > >> patches transitioning the code forward. > >> > >> That mail also mentions xenapi and hyperv. hyperv saw signs of life > >> afterwards and is still around. xenapi has been removed, along with uml. > >> > >> Considering the amount of code transitions we are currently undergoing > >> (gnulib, glib, memory auto cleanup, etc), phyp/ will probably have an > >> uptick of dev energy in the medium term. Let's bite the bullet and > >> remove it! > >> > >> docs/aclpolkit.html.in|4 - > >> docs/api.html.in |2 +- > >> docs/drivers.html.in |1 - > >> docs/drvphyp.html.in | 50 - > >> docs/schemas/capability.rng |3 +- > >> docs/schemas/domaincommon.rng |2 +- > >> libvirt.spec.in | 11 +- > >> m4/virt-driver-phyp.m4| 48 - > >> mingw-libvirt.spec.in |7 - > >> po/POTFILES.in|1 - > >> src/Makefile.am |1 - > >> src/README|1 - > >> src/libvirt.c | 10 - > >> src/phyp/Makefile.inc.am | 21 - > >> src/phyp/phyp_driver.c| 3739 - > >> src/phyp/phyp_driver.h| 24 - > >> 16 files changed, 4 insertions(+), 3921 deletions(-) > >> delete mode 100644 docs/drvphyp.html.in > >> delete mode 100644 m4/virt-driver-phyp.m4 > >> delete mode 100644 src/phyp/Makefile.inc.am > >> delete mode 100644 src/phyp/phyp_driver.c > >> delete mode 100644 src/phyp/phyp_driver.h > > > > Apart from what you proposed to squash in, I'd add/change the following: > > > > diff --git i/include/libvirt/virterror.h w/include/libvirt/virterror.h > > index 685e171235..7c7e5fd145 100644 > > --- i/include/libvirt/virterror.h > > +++ w/include/libvirt/virterror.h > > @@ -84,7 +84,7 @@ typedef enum { > > VIR_FROM_ONE = 27, /* The OpenNebula driver no longer exists. > > Retained for ABI/API compat only */ > > VIR_FROM_ESX = 28, /* Error from ESX driver */ > > -VIR_FROM_PHYP = 29, /* Error from IBM power hypervisor */ > > +VIR_FROM_PHYP = 29, /* Error from IBM power hypervisor; > > unused since 6.0.0 */ > > > > I'll add this, thanks > > > VIR_FROM_SECRET = 30, /* Error from secret storage */ > > VIR_FROM_CPU = 31, /* Error from CPU driver */ > > diff --git i/src/util/virhostcpu.c w/src/util/virhostcpu.c > > index 22102f2c75..f17a888638 100644 > > --- i/src/util/virhostcpu.c > > +++ w/src/util/virhostcpu.c > > @@ -650,7 +650,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, > > * If the user tampers the cpu online/offline states using chcpu or > > other > > * means, then it is an unsupported configuration for kvm. > > * The code below tries to keep in mind > > - * - when the libvirtd is run inside a KVM guest or Phyp based guest. > > + * - when the libvirtd is run inside a KVM guest. > > * - Or on the kvm host where user manually tampers the cpu states to > > *offline/online randomly. > > * On hosts other than POWER this will be 0, in which case a simpler > > @@ -1133,7 +1133,7 @@ virHostCPUGetThreadsPerSubcore(virArch arch) > > goto out; > > } > > > > -/* For Phyp and KVM based guests the ioctl for KVM_CAP_PPC_S
Re: [libvirt] [PATCH 0/1] Bug: Sandbox: libvirt breakdowns qemu guest
On 07/05/2018 - 11:29:57, Christian Borntraeger wrote: > On 05/07/2018 05:32 AM, Yi Min Zhao wrote: > > 1. Problem Description > > == > > If QEMU is built without seccomp support, 'elevatorprivileges' remains > > compiled. > > This option of sandbox is treated as an indication for seccomp blacklist > > support > > in libvirt. This behavior is introduced by the libvirt commits 31ca6a5 and > > 3527f9d. It would make libvirt build wrong QEMU cmdline, and then the guest > > startup would fail. > > Adding libvirt list. > > This would still fail with older QEMUs, so the question is if we should also > OR instead > change something in libvirt. Perhaps I'm missing something here, but libvirt can differentiate between different versions of QEMU, therefore not calling it with wrong or outdated arguments. > > > > > 2. Libvirt Log > > == > > qemu-system-s390x: -sandbox > > on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ > > resourcecontrol=deny: seccomp support is disabled > > > > 3. Fixup > > > > Wrap the options except 'enable' for qemu_sandbox_opts by CONFIG_SECCOMP. > > > > Yi Min Zhao (1): > > sandbox: avoid to compile options if CONFIG_SECCOMP undefined > > > > vl.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > -- Eduardo Otubo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Add Eduardo Otubo to Planet Virt-Tools
Adding Eduardo Otubo's blog information and avatar to config.ini at Planet Virt-Tools. Signed-ff-by: Eduardo Otubo --- updater/virt-tools/config.ini | 6 ++ updater/virt-tools/images/otubo.png | Bin 0 -> 10597 bytes 2 files changed, 6 insertions(+) create mode 100644 updater/virt-tools/images/otubo.png diff --git a/updater/virt-tools/config.ini b/updater/virt-tools/config.ini index 988e572..d47e82f 100644 --- a/updater/virt-tools/config.ini +++ b/updater/virt-tools/config.ini @@ -167,3 +167,9 @@ name = Nathan Gauër [https://virtualpenguins.blogspot.com/feeds/posts/default] name = Cornelia Huck + +[http://www.otubo.net/feeds/posts/default/-/virt/?alt=rss] +name = Eduardo Otubo +face = otubo.png +facewidth = 80 +faceheight = 80 diff --git a/updater/virt-tools/images/otubo.png b/updater/virt-tools/images/otubo.png new file mode 100644 index ..9dfd30fce1c7b06bac5ad9b07052ad170bbe768a GIT binary patch literal 10597 zcmZX41yEc;v+hE0cXxLW?y$HnESw)0002ksw#@0SFQ6OK|^^>lku-=Ulo#roTeNA z&V9+F1Z*o*KG%sgMhN+-op`t(1TZSW{;US@w0>W&ERP?AQ(GZ!!^zd@D zYDPa8hB2E(0i%Fi-`4ih*8Cp|d{@k_wxtC9&f-CiJmjjV*#*m;UiQ-uGTH$}@E6Jc zfOAL$^km$i@Snp=+G)KE;@|o)6~?ky7oqn{$F?;UEzAoNiMOKX9-)^w$5J@Zzc{F1 zNi;k}7_5Z?JIy}AI&<6QZgB0A60+4ElJMqs?K-+nvwLpK;0Xa9d@j@Y^jG zUJ3u7qv8hbPW}MI%$Ab{o_t<|SAQ`?(}ikFJ-{^rBTizHV~;}>E|i&A47uKQ$(MNe zfxQ*=^5kSFa}9LI;YZ<39*tp)w~qE9IhUG_xGj{z;153aqqV`ZcyfSC4paC)AuJfr zi^{1-0eEB{$)Jy4Le%HZU%U}JuGh$UWd4lYjfdh@iOL_vcF8c%CO0f>6^w{MZ<8A* zA#mTYKeoNTVZ^N};^&u07o4_lVi!^r@zvNOiSl3Ojlj>^-FH7wi*E}#iyjDuqSVnU zW>pjQb8SRR$Grl%Aqcdzk*MEsIuvM=HLUpyA43WV0KqA)t;#Bg>==YD*6G53!L-y z-`_8<@0vFP29el|Bnq4=a6qELJ$%s{R-t$)<>((pcgA-&0~7#1-3GI8EWxSUyPL{r zVPl>yb^tsO19CA^e<&&9A=5l(OEVa0T0)Y>ncE`N0|!Ze!P>*PS3G7w&zMlZ17#ih z!h+N-5WAg{eS;elGL54; zUA0!z_lhT6^Q@uuh}=+0;8;qeuD`@d6(s;;s~PDX)zHP|mG}+OsBj#({-Bsc?(j3+ z#Ny`bi+19Snh7tb`MUz63eIIlZfrMgFDA*aFtgZ2+T9_^Zw*o~9Q=yjp{eI%&II*mdeH5blxq}eEu`f zSlS17oiWB~nwM_R*$-KUNcLRn-!MzW4~ONu{W6!JUEL;9UYlktH|~WM(KHW$-fs&iAL&maI$`goiIEeBYYJD`f7uz7#z(?CpKYZYrSsEKVA3&j?t5)?*JmtSGORi=Ks*_ZL+@88KNBgjA&<~ zLqwiY8y@4`HyoweqmUS3)$`5K<5d3kWa6$QO&Gy#yy2fSsp+}E@Tdk!(k7xr5tT%`q|0cbjhoCPw655iQ zy1(`9!u;qRxiwYoG)K$9P=ZzpahXQk#g$qqz;h4Pqp{{E0@P>X{BhjTYgl^$%BZHr zd9FFMNM%)M>&N`rP-_}nUFR_(Ju{}?=5*f6#^&BI>ZYKs^WS#uwadoZ`k;h4_t0jN za;x`hN(N!=B*>2RI`Rxhv;?h0DxXv2AJK{{?esM)r!Cm??(bTs?X(>Q_e^e8j$s_y zFC2gWqKxG|Khge-fA@pqraB;~?l#5JWN%)iTTa)0vPe>O&9OMR_WNC9-x0@xDF?!F zne+w)0aBxmBYUd6Mn8I3RfXHhKdN2h_ciE0$k6DsYf7a3NckG!%RTd@7Tbk)&iHsX zQ1z>T=?%;^&UG6ZX7`WUv%yIR7-7_QE`hfm8X3*rGg1eEK1od+mugK5tEKeCpUXbG zhSigvv3B=aa!Mc~d1~jAO77H6*_f(T%GELZ+rTR|2Vkzbq0R6!q>#O#rDuzPpq<=2 zIu^_J5$`UuG;{o5DR%M-2@(}?S2U0sI!PX*d7I!J7I`y`5>#)s& z0YC4TgcHI~`t7{oH|bd2Z3wdELLiR(dhNfqi{~Cc{2(*H zpJ7+tp%R9?=p9pDmx+HjaYpyuW zIf}$FQ0J%BbN>`Qxoj2xMZgQgKxQMR=_c1pvhk+TBVn$@X*AabWfDV7bTgw%**?c( zWKovR6PPIv_)}Qm(fcYizLQeYKsdTBmAL$EEBGF5>>Utb!27f|({%I8jqm=1bTkQl zt_=X6DwKGOqfd=c)4;p2&SXOSGYD0=K5y1M$L^y?wALr!N^G2ukZu6~4Q@KXf3ep8 z++%@0vIgNN8v6x7(yxEcY z5>}qDvT+t&WUGs%4N8n~)nyHos<;)3EcV*PKB)S!9c}r-CNWdEy$9FQOEOr7xD;U1 zY!V*_6&W(LCr~a|{t@&p^J=i-65$uS{IYki>xN*y)!IFKclf8^> zJ%+WKMAg_E{@&=s7GvucXb>}~d`cUYFKJOy<_GPiIP}$v#lX^3*v(H=KqFfE?*7IX zHin*gv5u;*aZ(&nNtQus)mDyT^u)th6$XcV8}pNg%hzv2rVw2Nk0B7U;Tie5r1_xo=0RX5yv=tJcb^5 zO#_%W&K3$n{maP1`U63Qg&#-Wh$my-E(b*ESaO`5?mh z{Ut~S8Y`sz{AH8*TVRG#npM66fh31vI6(=DV#=VJEIS>l1p$rJ=HAvkVr>qO>WU%| zokL4Ei9~lrj>WY+xlg=H5Y24odtVl^FlF%smD%s5>i&JP4YEiO8ufMtB3zbz7Q@<> z4@D!27o+7Tll)ezQdPd>#HF2k2ne0Rw2_VpGhVcicP ztfe@{WZucfh7Ra{zks-Fi8q0)`szVTLLvp)=UziAK{iyd-s>+6<2Oy}F5~GD(Nk1a z1B&OtqNG$ya(%l#kwp6lXzw~FRr$6a7qXOhKoI^<&(G_qh<5j?=vgf5`A&N) z2ktH*A*z=6S-xUYT#Zyk#sW=^*&``?ImcxGmX@VpGbYg{a<-TtQG+dCo&vK?b_H=y zy}X%TcU!)N*(XwaervmCh@F^8>$6pFfwCxO#sFB|nyakKDx3IEG)IYKIX@gY-@g zkFv}~LQU84X-)8Hp85SG=~Cbh``XQo;+0V5c!VbnGqT70`@=2#uj;6Css!@X$A?gi zIvjtjiFn-}<&8}xF$D@$)1+*D&fL^;d}X2eY-8uh(q5#IJWZH0^@@BW%;eA zuEM_lE`Lx@umrD~kl-qLsYzaHco*hmS4_F9qJ4)CE5TNIndv2U@#k`1RZtv{0gJOWsOu1|N|(aluE!-mJMF z;60G;JA&w4qia3yzq|6(*Ii#JL9-V9Mib)m3^O~9hZ$?QCY$*dftXd%Z%`ywv6}E9 zCOZ1W4o2;e`z!H^&&FrMVqLS=ovWqf&P?G=)dvpDMh}cUF1TXt8v_y}mr>-&ywgo$ zWCB#8!KX&jy>WhzT&U*|!h(tlRq{W)o?R?}da3Tq*7|Gc%jL+dnoe$fa7gbZ;{#+d z=+@(+S1#8nv5oj+ho;z(E|wqJ-}cdHh5Wx{B^?bJm$g55ODlGG*ZtxL9!Qhs{HU_`?&h(Qm>L>jpg}bP=eT~`BzjH`wPTYR?hyYQj!(R` zbFuQG-WLbhkGC;2JF_JUi>)_{6^ixq*)<%OkfFW|j_WGvaoo)Kh;{Kzj0d$}cCyY~j%@lTqMmi+__iwuQ>3}Nf$SKk zU6R1o&Ut>DO+`VUZ5;T1S7476W0k0Jg1p~OR^$$K3QsB0b51nrcik>9qER=_9XB>g zSs4=Qc{_?oJ`GQ?| z_eX&cvG>IfoyxVQ@!wrp)foe;o9KA)+*Y2p^w8vqw7q>Mxjl2lFU_6uu_;tsx;FKW zKMbt)-?(z^7zDKy&|3bKV>Szk3l2`31bz9;x*rleeaQ-z1gy-( z2Ex)g2cEUEeA}nGJH>eN15z
Re: [libvirt] RFC: Drop unmaintained hv drivers? (phyp, xenapi, hyperv)
2016-04-15 21:54 GMT+02:00 Cole Robinson : > Hi all, > > There's a few old hypervisor drivers in the tree that haven't been actively > maintained for a long time. I'm curious if anyone knows of these drivers being > actively used. If not I think we should consider dropping them > > > src/phyp/ : for power VM hypervisor. Added in July 2009. The last commit that > looks like it wasn't either internal API conversion, or caught by code > analysis, is: > > commit 41461ff7f7d6ee6679aae2a8004e305c5830c9e8 > Author: Eduardo Otubo > Date: Tue Apr 19 12:34:08 2011 -0300 > > PHYP: Adding reboot domain function > > Adding reboot function for pHyp driver. > > Nearly 5 years ago. Eduardo is the primary driver author too (CCd at his email > from github). > > Searching the upstream bug tracker for all bugs with 'phyp', the only one > that's actually about the phyp driver is a report from 2 years ago that it > crashes trying to open a connection: > > https://bugzilla.redhat.com/show_bug.cgi?id=1093094 I developed this driver as per internal IBM project's request. I left IBM in 2014 and I really don't know if anyone uses this feature (internally or not) anymore. I'll try to check it out and get back to this thread as soon as I have some info. Regards, > > > src/xenapi/: Connecting to a xen api server. Added in March 2010. Largely > appears to be a code drop, the original author/committer has never had another > commit. The last xenapi specific commit seems to be: > > commit 484460ec4678a264c5e7355495c2f0da72cb42bd > Author: Matthias Bolte > Date: Thu Jul 21 15:16:11 2011 +0200 > > xenapi: Improve error reporting in xenapiOpen once again > > Nearly 5 years ago. The only upstream bug that was filed about xenapi is: > > https://bugzilla.redhat.com/show_bug.cgi?id=711372 > > Which was about a connection failure that was eventually fixed upstream, and > dovetailed into the above referenced commit. Current xen guys, you know of > anyone using this? > > > src/hyperv/: Added in July 2011. This was largely a code drop as well; > committed and patched a few times by Matthias but it was a university project > by someone else. Last hyperv targeted patch was: > > commit 9e9ea3ead9825bd1dc2c17cea4abc8c4165591d0 > Author: Matthias Bolte > Date: Sun Sep 9 17:39:40 2012 +0200 > > hyperv: Fix and improve hypervListAllDomains > > The driver is fairly minimal as well: it can only list existing VMs and > perform lifecycle operations. It can't create new VMs, and doesn't list VM > device config AFAICT. > > > Also, in general, I've never heard about anyone _actually_ using any of those > drivers in the wild. There's reports here and there but it mostly sounds like > people trying them out. Just an anecdote so take it with a grain of salt > > - Cole -- otubo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: rudimentary phyp documentation
On Thu, Sep 27, 2012 at 04:23:22PM -0600, Eric Blake wrote: > Based on a report that phyp is undocumented: > https://www.redhat.com/archives/libvirt-users/2012-July/msg00013.html > > * docs/drvphyp.html.in (phyp): New file. > * docs/drivers.html.in: List it. > --- > > Following up on an old thread. This is probably incomplete or > possibly even inaccurate, but I'd rather have something than nothing. > If I don't get any feedback within a week, I'm pushing this as-is. > > docs/drivers.html.in | 1 + > docs/drvphyp.html.in | 46 ++ > 2 files changed, 47 insertions(+) > create mode 100644 docs/drvphyp.html.in > > diff --git a/docs/drivers.html.in b/docs/drivers.html.in > index 24387d0..307d286 100644 > --- a/docs/drivers.html.in > +++ b/docs/drivers.html.in > @@ -29,6 +29,7 @@ >VMware > Workstation/Player >Xen >Microsoft > Hyper-V > + IBM PowerVM (phyp) > > > Storage drivers > diff --git a/docs/drvphyp.html.in b/docs/drvphyp.html.in > new file mode 100644 > index 000..7d97fa4 > --- /dev/null > +++ b/docs/drvphyp.html.in > @@ -0,0 +1,46 @@ > + > +IBM PowerVM hypervisor driver (phyp) > + > + > +The IBM PowerVM driver can manage both HMC and IVM PowerVM > +guests. VIOS connections are tunneled through HMC. > + > + > + > +Project Links > + > + > +The href="http://www-03.ibm.com/systems/power/software/virtualization/index.html";>IBM > +PowerVM hypervisor > + > + > + > + > +Connections to the PowerVM driver > + > +Some example remote connection URIs for the driver are: > + > + > +phyp://user@hmc/system (HMC connection) > +phyp://user@ivm/system (IVM connection) > + > + > +Note: In contrast to other drivers, the > +PowerVM (or phyp) driver is a client-side-only driver. Therefore, the > +remote transport mechanism provided by the > +remote driver and libvirtd will not work, and you cannot use URIs > like > +phyp+ssh://example.com. > + I think it whould be interesting to point that phyp uses ssh internally, so phyp+ssh would be redundant. > + > + > +URI Format > + > +URIs have this general form ([...] marks an > +optional part, {...|...} marks a mandatory choice). > + > + > +phyp://[username@]{hmc|ivm}/managed_system Actually, in the entire phyp URI is mandatory, the correct way should be: phyp://username@{hmc|ivm}/managed_system Or are you assuming that the username can be used from environment variable like in ssh? Regards, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] SIGTERM undeclared, virNetSocketFree
On 06/30/2011 01:51 PM, Jason Helfman wrote: On Thu, Jun 30, 2011 at 03:53:01PM +0100, Daniel P. Berrange thus spake: On Thu, Jun 30, 2011 at 07:36:24AM -0700, Jason Helfman wrote: Hi, I get this error when compiling 0.9.3-rc2 on FreeBSD. Is there a fix for this? rpc/virnetsocket.c: In function 'virNetSocketFree': rpc/virnetsocket.c:654: warning: implicit declaration of function 'kill' rpc/virnetsocket.c:654: warning: nested extern declaration of 'kill' [-Wnested-externs] rpc/virnetsocket.c:654: error: 'SIGTERM' undeclared (first use in this function) rpc/virnetsocket.c:654: error: (Each undeclared identifier is reported only once rpc/virnetsocket.c:654: error: for each function it appears in.) gmake[3]: *** [libvirt_net_rpc_la-virnetsocket.lo] Error 1 gmake[3]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.3/src' gmake[2]: *** [all] Error 2 gmake[2]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.3/src' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.3' gmake: *** [all] Error 2 *** Error code 1 We're using 'kill' without explicitly including signal.h. I suspect we're lucky to get it indirectly on Linux. Try this patch diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 96d2dfd..7e63d78 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef HAVE_NETINET_TCP_H # include Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| That fixed it, but now I am getting this: libvirtd-libvirtd.o(.text+0x1537): In function `daemonSetupNetworking': : undefined reference to `virNetSASLContextNewServer' libvirtd-remote.o(.text+0xe51e): In function `remoteSASLFinish': : undefined reference to `virNetSASLSessionGetKeySize' libvirtd-remote.o(.text+0xe578): In function `remoteSASLFinish': : undefined reference to `virNetSASLSessionGetIdentity' libvirtd-remote.o(.text+0xe5a8): In function `remoteSASLFinish': : undefined reference to `virNetSASLContextCheckIdentity' libvirtd-remote.o(.text+0xe5cb): In function `remoteSASLFinish': : undefined reference to `virNetServerClientSetSASLSession' libvirtd-remote.o(.text+0xe61e): In function `remoteSASLFinish': : undefined reference to `virNetSASLSessionGetIdentity' libvirtd-remote.o(.text+0xe67f): In function `remoteSASLFinish': : undefined reference to `virNetSASLSessionFree' libvirtd-remote.o(.text+0xe83a): In function `remoteDispatchAuthSaslStepHelper': : undefined reference to `virNetSASLSessionServerStep' libvirtd-remote.o(.text+0xe8a0): In function `remoteDispatchAuthSaslStepHelper': : undefined reference to `virNetSASLSessionFree' libvirtd-remote.o(.text+0xeaac): In function `remoteDispatchAuthSaslStepHelper': : undefined reference to `virNetSASLSessionGetIdentity' libvirtd-remote.o(.text+0xec78): In function `remoteDispatchAuthSaslStartHelper': : undefined reference to `virNetSASLSessionServerStart' libvirtd-remote.o(.text+0xecde): In function `remoteDispatchAuthSaslStartHelper': : undefined reference to `virNetSASLSessionFree' libvirtd-remote.o(.text+0xeeec): In function `remoteDispatchAuthSaslStartHelper': : undefined reference to `virNetSASLSessionGetIdentity' libvirtd-remote.o(.text+0xf10f): In function `remoteDispatchAuthSaslInitHelper': : undefined reference to `virNetSASLSessionFree' libvirtd-remote.o(.text+0xf157): In function `remoteDispatchAuthSaslInitHelper': : undefined reference to `virNetSASLSessionNewServer' libvirtd-remote.o(.text+0xf1a2): In function `remoteDispatchAuthSaslInitHelper': : undefined reference to `virNetSASLSessionSecProps' libvirtd-remote.o(.text+0xf1aa): In function `remoteDispatchAuthSaslInitHelper': : undefined reference to `virNetSASLSessionListMechanisms' libvirtd-remote.o(.text+0xf26e): In function `remoteDispatchAuthSaslInitHelper': : undefined reference to `virNetSASLSessionExtKeySize' libvirtd-remote.o(.text+0xf29b): In function `remoteDispatchAuthSaslInitHelper': : undefined reference to `virNetSASLSessionSecProps' gmake[3]: *** [libvirtd] Error 1 gmake[3]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.3/daemon' gmake[2]: *** [all] Error 2 gmake[2]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.3/daemon' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.3' gmake: *** [all] Error 2 *** Error c
[libvirt] [PATCH] PHYP: Adding reboot domain function
Adding reboot function for pHyp driver. --- src/phyp/phyp_driver.c | 35 ++- 1 files changed, 34 insertions(+), 1 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index bb0e0ac..228751d 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3384,6 +3384,39 @@ cleanup: } static int +phypDomainReboot(virDomainPtr dom) +{ +int result = -1; +ConnectionData *connection_data = dom->conn->networkPrivateData; +virConnectPtr conn = dom->conn; +LIBSSH2_SESSION *session = connection_data->session; +phyp_driverPtr phyp_driver = conn->privateData; +int system_type = phyp_driver->system_type; +char *managed_system = phyp_driver->managed_system; +int exit_status = 0; +char *ret = NULL; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virBufferAddLit(&buf, "chsysstate"); +if (system_type == HMC) +virBufferVSprintf(&buf, " -m %s", managed_system); +virBufferVSprintf(&buf, + " -r lpar -o shutdown --id %d --immed --restart", + dom->id); +ret = phypExecBuffer(session, &buf, &exit_status, dom->conn, false); + +if (exit_status < 0) +goto cleanup; + +result = 0; + + cleanup: +VIR_FREE(ret); + +return result; +} + +static int phypDomainShutdown(virDomainPtr dom) { int result = -1; @@ -3707,7 +3740,7 @@ static virDriver phypDriver = { NULL, /* domainSuspend */ phypDomainResume, /* domainResume */ phypDomainShutdown, /* domainShutdown */ -NULL, /* domainReboot */ +phypDomainReboot, /* domainReboot */ phypDomainDestroy, /* domainDestroy */ NULL, /* domainGetOSType */ NULL, /* domainGetMaxMemory */ -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv6] PHYP: Adding network interface
This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 * Interface name: U9124.720.067BE8B-V3-C0 * I did replaced all the |grep|sed following the comments Eric Blake did on the last patch. * According to my last email, It's not possible to create a network interface without assigning it to a specific lpar. Then, I am using this very minimalistic XML file for testing: In this file I am using "name" as the lpar name which I am going to assign the new network interface. I couldn't find a better way to refer to it. Comments are welcome. * Regarding the fact I am sleeping one second waiting for the HMC to complete creation of the interface, I don't have means to check if the whole process is done. All I do is execute a command, wait until is complete (which is not enough in this case) check the return and the exit status. The process of actually creating a networking interface seems to take a little longer than just the return of the ssh control. --- src/phyp/phyp_driver.c | 583 ++-- 1 files changed, 564 insertions(+), 19 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 51f9ff6..b8e7b2f 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -59,6 +59,7 @@ #include "storage_conf.h" #include "nodeinfo.h" #include "files.h" +#include "interface_conf.h" #include "phyp_driver.h" @@ -74,6 +75,8 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -3273,6 +3276,552 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) } static int +phypInterfaceDestroy(virInterfacePtr iface, + unsigned int flags) +{ +virCheckFlags(0, -1); + +ConnectionData *connection_data = iface->conn->networkPrivateData; +phyp_driverPtr phyp_driver = iface->conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +int slot_num = 0; +int lpar_id = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; + +/* Getting the remote slot number */ + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,slot_num|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &slot_num) == -1) +goto err; + +/* Getting the remote slot number */ +VIR_FREE(cmd); +VIR_FREE(ret); + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,lpar_id|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +cmd = virBufferContentAndReset(&buf); + +VIR_FREE(ret); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1) +goto err; + +/* excluding interface */ +VIR_FREE(cmd); +VIR_FREE(ret); + +virBufferAddLit(&buf, "chhwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth" + " --id %d -o r -s %d", lpar_id, slot_num); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +VIR_FREE(ret); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || r
Re: [libvirt] [PATCHv5] PHYP: Adding network interface management
rBufferVSprintf(&buf, +" -r virtualio --rsubtype eth" +" -p %s -o r -s %d", def->name, slot); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +goto err; + } + + char_ptr = strchr(ret, '\n'); + +memcpy(name, ret, PHYP_IFACENAME_SIZE-1); This doesn't guarantee that name is NUL-terminated (and it's wasteful if name is much shorter than PHYP_IFACENAME_SIZE). Are you sure that's okay... The name of the interface is generated automatically and has exactly PHYP_IFACENAME_SIZE characters. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv5] PHYP: Adding network interface management
This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 * Interface name: U9124.720.067BE8B-V3-C0 * I did replaced all the |grep|sed following the comments Eric Blake did on the last patch. * According to my last email, It's not possible to create a network interface without assigning it to a specific lpar. Then, I am using this very minimalistic XML file for testing: In this file I am using "name" as the lpar name which I am going to assign the new network interface. I couldn't find a better way to refer to it. Comments are welcome. * Regarding the fact I am sleeping one second waiting for the HMC to complete creation of the interface, I don't have means to check if the whole process is done. All I do is execute a command, wait until is complete (which is not enough in this case) check the return and the exit status. The process of actually creating a networking interface seems to take a little longer than just the return of the ssh control. --- src/phyp/phyp_driver.c | 648 +--- 1 files changed, 562 insertions(+), 86 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index d954f2a..0b9c030 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -59,6 +59,7 @@ #include "storage_conf.h" #include "nodeinfo.h" #include "files.h" +#include "interface_conf.h" #include "phyp_driver.h" @@ -74,6 +75,8 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -1113,8 +1116,10 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, static virDrvOpenStatus phypOpen(virConnectPtr conn, - virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) + virConnectAuthPtr auth, int flags) { +virCheckFlags(0, VIR_DRV_OPEN_DECLINED); + LIBSSH2_SESSION *session = NULL; ConnectionData *connection_data = NULL; char *string = NULL; @@ -1125,6 +1130,7 @@ phypOpen(virConnectPtr conn, char *char_ptr; char *managed_system = NULL; + if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -1176,9 +1182,6 @@ phypOpen(virConnectPtr conn, * */ char_ptr = strchr(managed_system, '/'); -if (char_ptr) -*char_ptr = '\0'; - if (escape_specialcharacters(conn->uri->path, string, len) == -1) { PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1354,11 +1357,6 @@ phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system, if (exit_status < 0 || ret == NULL) goto err; -char *char_ptr = strchr(ret, '\n'); - -if (char_ptr) -*char_ptr = '\0'; - VIR_FREE(cmd); return ret; @@ -1436,9 +1434,6 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, char_ptr = strchr(ret, '\n'); -if (char_ptr) -*char_ptr = '\0'; - if (virStrToLong_i(ret, &char_ptr, 10, &memory) == -1) goto err; @@ -1488,9 +1483,6 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, char_ptr = strchr(ret, '\n'); -if (char_ptr) -*char_ptr = '\0'; - if (virStrToLong_i(ret, &char_ptr, 10, &vcpus) == -1) goto err; @@ -1565,9 +1557,6 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system, char_ptr = strchr(ret, '\n'); -if (char_ptr) -*char_ptr = '\0'; - if (virStrToLong_i(ret, &char_ptr, 10, &remote_slot) == -1) goto err; @@ -1650,9 +1639,6 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system, char_ptr = strchr(backing_device, '\n'); -if (char_ptr) -*char_ptr = '\0'; - VIR_FREE(cmd); VIR_FREE(ret); return backing_device; @@ -1694,11 +1680,6 @@ phypGetLparProfile(virConnectPtr conn, int lpar_id) if (exit_status < 0 || ret == NULL) goto err; -char *char_ptr = strchr(ret, '\n'); - -if (char_ptr) -*char_ptr = '\0'; - VIR_FREE(cmd); return ret; @@ -1916,11 +1897,6 @@ phypGetVIOSFreeSCSIAdapter(virConnectPtr conn) if (exit_status < 0 || ret == NULL) goto err; -char *char_ptr = strchr(ret, '\n'); - -if (char_ptr) -*char_ptr = '\0'; - VIR_FREE(cmd); return ret; @@ -2178,13 +2154,7 @@ phypVolumeGetKey(virConnectPtr conn, char *key, const char *name) if (exit_status < 0 || ret == NULL) goto err; -char *char_ptr
Re: [libvirt] [PATCHv4] PHYP: Adding network interface management
On 01/14/2011 10:07 PM, Eric Blake wrote: On 12/29/2010 11:04 AM, Eduardo Otubo wrote: This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: Finally getting around to reviewing this again. I'm not intentionally putting you off, it's just that I'm less familiar with phyp and it takes a good chunk of free time to review large patches in areas where I'm less familiar. No problem, I understand your point on not having a way to test it. In, future work, I'll try to send smaller patches so it gets much easier for you all to review. And sorry for the delay on replying this email, I was on a vacation, so catching up all now. @@ -74,6 +75,11 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; + + +virCheckFlags(0,NULL); This is misplaced, and causes a compile error. It should be one of the first statements (not declarations) in any function that takes a flags argument where you do not otherwise use flags, and not something done at the file scope. static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -1113,7 +1119,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, static virDrvOpenStatus phypOpen(virConnectPtr conn, - virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) + virConnectAuthPtr auth, int flags) { LIBSSH2_SESSION *session = NULL; ConnectionData *connection_data = NULL; That is, somewhere in this function. Seeing as how this causes a compile error: CC libvirt_driver_phyp_la-phyp_driver.lo phyp/phyp_driver.c:82:1: error: expected identifier or '(' before 'do' phyp/phyp_driver.c:82:290: error: expected identifier or '(' before 'while' cc1: warnings being treated as errors phyp/phyp_driver.c: In function 'phypOpen': phyp/phyp_driver.c:1122:38: error: unused parameter 'flags' [-Wunused-parameter] phyp/phyp_driver.c: In function 'phypInterfaceDestroy': how can I even be sure that you've tested your patch, to spend my time reviewing it? Works for me. otubo@vader ~ $ uname -a Linux vader 2.6.35-25-generic #44-Ubuntu SMP Fri Jan 21 17:40:48 UTC 2011 i686 GNU/Linux otubo@vader ~/develop/libvirt master $ gcc -v Using built-in specs. Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) Don't know why or how, but it did compiled. I'll fix again and send it. +static virInterfacePtr +phypInterfaceDefineXML(virConnectPtr conn, const char *xml, + unsigned int flags) +{ +/* Now adding the new network interface */ +virBufferAddLit(&buf, "chhwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth" + " -p %s -o a -s %d -a port_vlan_id=1," + "ieee_virtual_eth=0", def->name, slot); So if this succeeds, +/* Need to sleep a little while to wait for the HMC to + * complete the execution of the command. + * */ +sleep(1); + +/* Getting the new interface name */ +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype slot --level slot" + " |sed '/lpar_name=%s/!d; /slot_num=%d/!d; " + "s/^.*drc_name=//'", def->name, slot); but this fails, do you need to undo the reservation, or have you just leaked a resource? I put now a roll-back on this part in case it couldn't get the correct interface name. + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +cmd = virBufferCon
Re: [libvirt] [PATCHv4] PHYP: Adding network interface management
Any chance to get a review for the next release? Thanks a lot :-) Regards, On 12/29/2010 04:04 PM, Eduardo Otubo wrote: This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 * Interface name: U9124.720.067BE8B-V3-C0 * I did replaced all the |grep|sed following the comments Eric Blake did on the last patch. * According to my last email, It's not possible to create a network interface without assigning it to a specific lpar. Then, I am using this very minimalistic XML file for testing: In this file I am using "name" as the lpar name which I am going to assign the new network interface. I couldn't find a better way to refer to it. Comments are welcome. * Regarding the fact I am sleeping one second waiting for the HMC to complete creation of the interface, I don't have means to check if the whole process is done. All I do is execute a command, wait until is complete (which is not enough in this case) check the return and the exit status. The process of actually creating a networking interface seems to take a little longer than just the return of the ssh control. --- src/phyp/phyp_driver.c | 572 ++-- 1 files changed, 551 insertions(+), 21 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 3508891..62a38a2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -59,6 +59,7 @@ #include "storage_conf.h" #include "nodeinfo.h" #include "files.h" +#include "interface_conf.h" #include "phyp_driver.h" @@ -74,6 +75,11 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; + + +virCheckFlags(0,NULL); static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -1113,7 +1119,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, static virDrvOpenStatus phypOpen(virConnectPtr conn, - virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) + virConnectAuthPtr auth, int flags) { LIBSSH2_SESSION *session = NULL; ConnectionData *connection_data = NULL; @@ -3273,6 +3279,535 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) } static int +phypInterfaceDestroy(virInterfacePtr iface, + unsigned int flags) +{ +ConnectionData *connection_data = iface->conn->networkPrivateData; +phyp_driverPtr phyp_driver = iface->conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +int slot_num = 0; +int lpar_id = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; + +/* Getting the remote slot number */ + +char_ptr = strchr(iface->mac, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,slot_num|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd,&exit_status, iface->conn); + +if (exit_status< 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret,&char_ptr, 10,&slot_num) == -1) +goto err; + +/* Getting the remote slot number */ +VIR_FREE(cmd); +VIR_FREE(ret); + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,lpar_id|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +c
[libvirt] [PATCHv4] PHYP: Adding network interface management
This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 * Interface name: U9124.720.067BE8B-V3-C0 * I did replaced all the |grep|sed following the comments Eric Blake did on the last patch. * According to my last email, It's not possible to create a network interface without assigning it to a specific lpar. Then, I am using this very minimalistic XML file for testing: In this file I am using "name" as the lpar name which I am going to assign the new network interface. I couldn't find a better way to refer to it. Comments are welcome. * Regarding the fact I am sleeping one second waiting for the HMC to complete creation of the interface, I don't have means to check if the whole process is done. All I do is execute a command, wait until is complete (which is not enough in this case) check the return and the exit status. The process of actually creating a networking interface seems to take a little longer than just the return of the ssh control. --- src/phyp/phyp_driver.c | 572 ++-- 1 files changed, 551 insertions(+), 21 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 3508891..62a38a2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -59,6 +59,7 @@ #include "storage_conf.h" #include "nodeinfo.h" #include "files.h" +#include "interface_conf.h" #include "phyp_driver.h" @@ -74,6 +75,11 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; + + +virCheckFlags(0,NULL); static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -1113,7 +1119,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, static virDrvOpenStatus phypOpen(virConnectPtr conn, - virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) + virConnectAuthPtr auth, int flags) { LIBSSH2_SESSION *session = NULL; ConnectionData *connection_data = NULL; @@ -3273,6 +3279,535 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) } static int +phypInterfaceDestroy(virInterfacePtr iface, + unsigned int flags) +{ +ConnectionData *connection_data = iface->conn->networkPrivateData; +phyp_driverPtr phyp_driver = iface->conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +int slot_num = 0; +int lpar_id = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; + +/* Getting the remote slot number */ + +char_ptr = strchr(iface->mac, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,slot_num|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &slot_num) == -1) +goto err; + +/* Getting the remote slot number */ +VIR_FREE(cmd); +VIR_FREE(ret); + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,lpar_id|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +goto err; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1) +goto err; + +/* excluding interface */ +VIR_FREE(cmd); +VIR_FREE(ret); + +virBufferAddLit(&buf, "chhwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, +
Re: [libvirt] [PATCHv3] PHYP: Adding network interface management
On 12/14/2010 02:27 PM, Eric Blake wrote: On 12/13/2010 01:09 PM, Eduardo Otubo wrote: This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: You may want to use --enable-compile-warnings=error at autogen.sh time, since it would have caught this bug: I actually didn't know about this option. Will use as default options from now on, thanks. CC libvirt_driver_phyp_la-phyp_driver.lo cc1: warnings being treated as errors phyp/phyp_driver.c:4633:5: error: initialization from incompatible pointer type make[2]: *** [libvirt_driver_phyp_la-phyp_driver.lo] Error 1 Fixed by making phypListInterfaces return int. Ack, fixed. static int +phypInterfaceDestroy(virInterfacePtr iface, + unsigned int flags ATTRIBUTE_UNUSED) +{ +ret = phypExec(session, cmd,&exit_status, iface->conn); + + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; Memory leak for ret; this should goto err rather than return. Ack, fixed. +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd,&exit_status, iface->conn); Memory leak for the old value of ret; you need to VIR_FREE the old value before starting a new phypExec, or track the exec's in separate strings all of which get freed at the end. Ack, fixed. +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd,&exit_status, iface->conn); Two more leaks of ret. Ack, fixed. + +static virInterfacePtr +phypInterfaceDefineXML(virConnectPtr conn, const char *xml, + unsigned int flags ATTRIBUTE_UNUSED) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +char *char_ptr; +char *cmd = NULL; +int slot = 0; +char *ret = NULL; +char name[PHYP_IFACENAME_SIZE]; +char mac[PHYP_MAC_SIZE]; +virInterfaceDefPtr def; + Rather than marking flags as unused, it would be better to insert virCheckFlags(0,NULL). Ack, fixed. + +ret = phypExec(session, cmd,&exit_status, conn); + +if (exit_status< 0 || ret == NULL) Can exit_status ever be less than 0? Or does it reflect the same values as a process exit status, where things like WIFEXITED apply, and where the result will always be in the range of uint16_t? But that's a question for the entire file, and not just this patch. Yes, exit_status can assume values less than zero. Actually HMC has lots of error message numbers, not exactly in the standards, so unfortunately int would fit better for this variable. + +ret = phypExec(session, cmd,&exit_status, conn); Another case of leaking the old value of ret. Ack, fixed. + +ret = phypExec(session, cmd,&exit_status, conn); and another. Ack, fixed. + +ret = phypExec(session, cmd,&exit_status, conn); and another. Ack, fixed. +static virInterfacePtr +phypInterfaceLookupByName(virConnectPtr conn, const char *name) +{ + +ret = phypExec(session, cmd,&exit_status, conn); +ret = phypExec(session, cmd,&exit_status, conn); and another. Ack, fixed. +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return NULL; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd,&exit_status, conn); again Ack, fixed. + +if (exit_status< 0 || ret == NULL) +goto err; + +if (memcpy(mac, ret, PHYP_MAC_SIZE-1) == NULL) +goto err; + +VIR_FREE(cmd); +VIR_FREE(ret); +return virGetInterface(conn, name, ret); NULL pointer dereference, because you're trying to use ret after freeing it. Ack, fixed. +static int +phypNumOfInterfaces(virConnectPtr conn) +{ + +if (virStrToLong_i(ret,&char_ptr, 10,&nnets) == -1) +goto err; + +if (char_ptr) +*char_ptr = '\0'; What's this for? You don't use char_ptr in the rest of the function, and you're about to free ret, which is where char_ptr points. Yes, legacy code probably, sorry I didn't noticed this earlier. Sending the PATCHv4 right away, keeping all the same comments Thanks for the review. Regards and happy new year. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv3] PHYP: Adding network interface management
This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 * Interface name: U9124.720.067BE8B-V3-C0 * I did replaced all the |grep|sed following the comments Eric Blake did on the last patch. * According to my last email, It's not possible to create a network interface without assigning it to a specific lpar. Then, I am using this very minimalistic XML file for testing: In this file I am using "name" as the lpar name which I am going to assign the new network interface. I couldn't find a better way to refer to it. Comments are welcome. * Regarding the fact I am sleeping one second waiting for the HMC to complete creation of the interface, I don't have means to check if the whole process is done. All I do is execute a command, wait until is complete (which is not enough in this case) check the return and the exit status. The process of actually creating a networking interface seems to take a little longer than just the return of the ssh control. --- src/phyp/phyp_driver.c | 565 ++-- 1 files changed, 546 insertions(+), 19 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 3508891..40760a5 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -59,6 +59,7 @@ #include "storage_conf.h" #include "nodeinfo.h" #include "files.h" +#include "interface_conf.h" #include "phyp_driver.h" @@ -74,6 +75,8 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -3273,6 +3276,535 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) } static int +phypInterfaceDestroy(virInterfacePtr iface, + unsigned int flags ATTRIBUTE_UNUSED) +{ +ConnectionData *connection_data = iface->conn->networkPrivateData; +phyp_driverPtr phyp_driver = iface->conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +int slot_num = 0; +int lpar_id = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; + +/* Getting the remote slot number */ + +char_ptr = strchr(iface->mac, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,slot_num|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &slot_num) == -1) +goto err; + +/* Getting the remote slot number */ + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,lpar_id|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1) +goto err; + +/* excluding interface */ + +virBufferAddLit(&buf, "chhwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth" + " --id %d -o r -s %d", lpar_id, slot_num); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret != NULL) +goto err; + +VIR_F
Re: [libvirt] [PATCHv2] PHYP: Adding network interface management
On 12/09/2010 07:16 PM, Eric Blake wrote: On 11/22/2010 06:03 PM, Eduardo Otubo wrote: Apologies for my review backlog (if you haven't guessed, I sometimes table big patches for later, then forget to come back rapidly). No problem, I'll try to post earlier next time. Thanks anyway. This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 HMC represents MAC as a decimal number? How hideous, but not your fault; and this comment in the commit message will be useful for anyone auditing the code in the future. Yeah, no way I understand this notation either. Keeping all the commit comments on the PATCHv3 I'll send right away. +/* Getting the remote slot number */ + +char_ptr = NULL; +char_ptr = strchr(iface->mac, '\n'); Redundant assignments (delete the first line). ACK, fixed. +if (VIR_ALLOC_N(name, PHYP_IFACENAME_SIZE)< 0) { +virReportOOMError(); +goto err; +} + +if (VIR_ALLOC_N(mac, PHYP_MAC_SIZE)< 0) { +virReportOOMError(); +goto err; +} Since these arrays are so small, it's faster to just stack-allocate them: char name[PHYP_IFACENAME_SIZE]; ACK, fixed. +/* The next free slot itself: */ +slot++; + +/* Now addig the new network interface */ s/addig/adding/ ACK, fixed. +if (exit_status< 0 || ret == NULL) +goto err; + +char_ptr = NULL; +char_ptr = strchr(ret, '\n'); Another redundant assignment. ACK, fixed. +if (memcpy(mac, ret, PHYP_IFACENAME_SIZE) == NULL) +goto err; + +VIR_FREE(cmd); +VIR_FREE(ret); +return virGetInterface(conn, name, mac); + + err: +VIR_FREE(name); +VIR_FREE(cmd); +VIR_FREE(ret); +return NULL; This leaks name if you end up calling virGetInterface. And both paths leak mac. But if you change name and mac to be stack-allocated, then you don't have to worry about freeing them. ACK, fixed. +ret = phypExec(session, cmd,&exit_status, conn); + +if (exit_status< 0 || ret == NULL) +goto err; + +VIR_FREE(cmd); +return virGetInterface(conn, name, ret); + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return NULL; This leaks ret if virGetInterface is called. ACK, fixed. +ret = phypExec(session, cmd,&exit_status, iface->conn); + +if (exit_status< 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret,&char_ptr, 10,&state) == -1) +goto err; + +if (char_ptr) +*char_ptr = '\0'; + +VIR_FREE(cmd); +return state; Another leak of ret. ACK, fixed. +static int +phypListInterfaces(virConnectPtr conn, char **const names, int nnames) s/int/size_t/ +ret = phypExec(session, cmd,&exit_status, conn); + +/* I need to parse the textual return in order to get the network interfaces */ +if (exit_status< 0 || ret == NULL) +goto err; +else { Rather than indenting the rest of the function inside an else{} block, you can leave the code at the top level indentation since the if() block was an unconditional goto. ACK, fixed. +ret = phypExec(session, cmd,&exit_status, conn); + +if (exit_status< 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret,&char_ptr, 10,&nnets) == -1) +goto err; + +if (char_ptr) +*char_ptr = '\0'; + +VIR_FREE(cmd); +return nnets; Another leak of ret. ACK, fixed. int @@ -4117,7 +4651,7 @@ phypRegister(void) return -1; if (virRegisterStorageDriver(&phypStorageDriver)< 0) return -1; -if (virRegisterNetworkDriver(&phypNetworkDriver)< 0) +if (virRegisterInterfaceDriver(&phypInterfaceDriver)< 0) Are you intending to replace NetworkDriver with InterfaceDriver, or should you be supporting both drivers simultaneously (although this may be more an indication of how unfamiliar I am with the difference between what the two drivers are supposed to provide). First option, I'll replace NetworkDriver with InterfaceDriver. I didn't know that there were an Interface API, my deep fault on this matter. As I said, I will keep all the commit comments for further needs. Sending now the PATCHv3. Thanks for the review. Regards, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2] PHYP: Adding network interface management
Sorry for the tops posting, but I was wondering if someone could take a look at my patch v2, thanks. Regards, On 11/22/2010 11:03 PM, Eduardo Otubo wrote: This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 * Interface name: U9124.720.067BE8B-V3-C0 * I did replaced all the |grep|sed following the comments Eric Blake did on the last patch. * According to my last email, It's not possible to create a network interface without assigning it to a specific lpar. Then, I am using this very minimalistic XML file for testing: In this file I am using "name" as the lpar name which I am going to assign the new network interface. I couldn't find a better way to refer to it. Comments are welcome. * Regarding the fact I am sleeping one second waiting for the HMC to complete creation of the interface, I don't have means to check if the whole process is done. All I do is execute a command, wait until is complete (which is not enough in this case) check the return and the exit status. The process of actually creating a networking interface seems to take a little longer than just the return of the ssh control. --- src/phyp/phyp_driver.c | 572 ++-- 1 files changed, 553 insertions(+), 19 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 4c723a2..407f644 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -59,6 +59,7 @@ #include "storage_conf.h" #include "nodeinfo.h" #include "files.h" +#include "interface_conf.h" #include "phyp_driver.h" @@ -74,6 +75,8 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -3268,6 +3271,542 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) } static int +phypInterfaceDestroy(virInterfacePtr iface, + unsigned int flags ATTRIBUTE_UNUSED) +{ +ConnectionData *connection_data = iface->conn->networkPrivateData; +phyp_driverPtr phyp_driver = iface->conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +int slot_num = 0; +int lpar_id = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; + +/* Getting the remote slot number */ + +char_ptr = NULL; +char_ptr = strchr(iface->mac, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,slot_num|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd,&exit_status, iface->conn); + +if (exit_status< 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret,&char_ptr, 10,&slot_num) == -1) +goto err; + +/* Getting the remote slot number */ + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,lpar_id|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd,&exit_status, iface->conn); + +if (exit_status< 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret,&char_ptr, 10,&lpar_id) == -1) +goto err; + +/* excluding interface */ + +virBufferAddLit(&buf, "chhwres "); +if (syst
[libvirt] [PATCHv2] PHYP: Adding network interface management
This is the implementation of the previous patch now using virInterface* API. Ended up this patch got much more simpler, smaller and easier to review. Here is some details: * MAC size and interface name are fixed due to specifications on HMC, both are created automatically and CAN'T be specified from user. They have the following format: * MAC: 122980003002 * Interface name: U9124.720.067BE8B-V3-C0 * I did replaced all the |grep|sed following the comments Eric Blake did on the last patch. * According to my last email, It's not possible to create a network interface without assigning it to a specific lpar. Then, I am using this very minimalistic XML file for testing: In this file I am using "name" as the lpar name which I am going to assign the new network interface. I couldn't find a better way to refer to it. Comments are welcome. * Regarding the fact I am sleeping one second waiting for the HMC to complete creation of the interface, I don't have means to check if the whole process is done. All I do is execute a command, wait until is complete (which is not enough in this case) check the return and the exit status. The process of actually creating a networking interface seems to take a little longer than just the return of the ssh control. --- src/phyp/phyp_driver.c | 572 ++-- 1 files changed, 553 insertions(+), 19 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 4c723a2..407f644 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -59,6 +59,7 @@ #include "storage_conf.h" #include "nodeinfo.h" #include "files.h" +#include "interface_conf.h" #include "phyp_driver.h" @@ -74,6 +75,8 @@ static unsigned const int HMC = 0; static unsigned const int IVM = 127; +static unsigned const int PHYP_IFACENAME_SIZE = 24; +static unsigned const int PHYP_MAC_SIZE= 12; static int waitsocket(int socket_fd, LIBSSH2_SESSION * session) @@ -3268,6 +3271,542 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) } static int +phypInterfaceDestroy(virInterfacePtr iface, + unsigned int flags ATTRIBUTE_UNUSED) +{ +ConnectionData *connection_data = iface->conn->networkPrivateData; +phyp_driverPtr phyp_driver = iface->conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +int slot_num = 0; +int lpar_id = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; + +/* Getting the remote slot number */ + +char_ptr = NULL; +char_ptr = strchr(iface->mac, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,slot_num|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &slot_num) == -1) +goto err; + +/* Getting the remote slot number */ + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,lpar_id|" + " sed -n '/%s/ s/^.*,//p'", iface->mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1) +goto err; + +/* excluding interface */ + +virBufferAddLit(&buf, "chhwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth" + " --id %d -o r -s %d", lpar_id, slot_num); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, iface->conn); + +if (exit_status < 0 || ret != NULL) +goto err; + +VIR_F
Re: [libvirt] [PATCH 1/3] PHYP: Separating UUID functions in another file
On 11/19/2010 07:37 PM, Eric Blake wrote: On 11/19/2010 07:55 AM, Eduardo Otubo wrote: I am moving all the UUID handling functions to phyp_uuid.[ch] files in order not to bloat the main files phyp_driver.[ch] too much. Doing this for two reasons: 1) Network management in pHyp does not have a UUID. 2) Need to create another set of functions to manage it. I also modified some functions to support two types of execution: DOMAIN and NET, so I can re-use the base common functions. --- po/POTFILES.in |1 + src/Makefile.am|3 +- src/phyp/phyp_driver.c | 464 +- src/phyp/phyp_driver.h | 41 +++ src/phyp/phyp_uuid.c | 657 src/phyp/phyp_uuid.h | 36 +++ 6 files changed, 742 insertions(+), 460 deletions(-) create mode 100644 src/phyp/phyp_uuid.c create mode 100644 src/phyp/phyp_uuid.h [I've rearranged my review a bit; .h before .c] diff --git a/src/phyp/phyp_uuid.h b/src/phyp/phyp_uuid.h new file mode 100644 index 000..ddf28f4 --- /dev/null +++ b/src/phyp/phyp_uuid.h @@ -0,0 +1,36 @@ + +/* + * Copyright (C) 2010 Red Hat, Inc. + * Copyright IBM Corp. 2010 + * + * phyp_uuid.c: set of functions to handle lpar uuid and network uuid + * which does not have uuid itself, it must be artificially + * created. + * ... + +#include While there are other counter-examples currently in libvirt.git, the general rule of thumb tends to be that .c files should include config.h first before any headers, and therefore .h files should not include it (because it will already have been included by the .c file including this .h). And regarding all your comments, I'll fix and reply in my next patch using virInterface API. Thank you very much for all the comments. :) Regards, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] PHYP: Adding network management support
On 11/22/2010 12:52 PM, Daniel P. Berrange wrote: On Fri, Nov 19, 2010 at 12:55:03PM -0200, Eduardo Otubo wrote: This is a series of 3 patches to add network management support for pHyp driver. Can you explain what sort of network connectivity you are managing here ? The virNetwork APIs are specifically for an IP layer virtual switch, that does IP forwarding, optionally with NAT. Reading the patches, it sounds more like you're trying to represent ethernet layer virtual switches (aka bridging to physical NICs). This is what the virInterface APIs are intended to cover So if my understanding is correct you need to implement the virInterface APIs rather than virNetwork APIs I guess you're right. My initial idea was to describe the management of network interfaces. I was not aware of this virInterface API. Perhaps I should re write from the beginning, which will not take long since I have all the command calls ready and logic fresh in my head. Thanks you very much for the comment, will send a patch soon. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] PHYP: create, destroy and other network functions
Adding networkCreateXML, networkDestroy, networkIsActive and networkLookupByName. In the function phypCreateNetwork I just use the def->domain information to create the new network interface because of the behaviour of the HMC and the hypervisor: * HMC can't simply create a network interface without assigning it to a specific LPAR. * I also can't assign an IP addr or any other information from the HMC or VIOS side, but I can control in which vlan or vswitch it will be attached - but thought just in the simplest case scenarion now, I'll make some improvements in the future. That's why I used a very simple XML for testing: 3e3fce45-4f53-4fa7-bb32-11f34168b82b whatever The only information I really need is the domain name which I'll assign the created network interface. Name, MAC Addr MUST be created automatically by the hypervisor, they're all unique. I had to put those two other tags "name" and "bridge" so the function virNetworkDefParseString can return successfully, otherwise it would say that the XML is malformed. --- src/phyp/phyp_driver.c | 400 +++- src/phyp/phyp_driver.h |2 +- 2 files changed, 396 insertions(+), 6 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index c44fc69..244561e 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2010 Red Hat, Inc. - * Copyright IBM Corp. 2009 + * Copyright IBM Corp. 2010 * * phyp_driver.c: ssh layer to access Power Hypervisors * @@ -2829,6 +2829,396 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) return NULL; } +static int +networkDestroy(virNetworkPtr net) +{ +ConnectionData *connection_data = net->conn->networkPrivateData; +phyp_driverPtr phyp_driver = net->conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +virBuffer buf = VIR_BUFFER_INITIALIZER; +uuid_nettablePtr uuid_nettable = phyp_driver->uuid_nettable; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +int slot_num = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; +unsigned int i = 0; +int lpar_id = 0; +long long mac = 0; + +for (i = 0; i < uuid_nettable->nnets; i++) { +if (STREQ(uuid_nettable->nets[i]->name, net->name)) { +mac = uuid_nettable->nets[i]->mac; +break; +} +} + +/* Getting the LPAR ID */ + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype slot --level slot " + " -F drc_name,lpar_id|grep %s|" + " sed -e 's/^.*,//g'", net->name); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, net->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1) +goto err; + +/* Getting the remote slot number */ + +virBufferAddLit(&buf, "lshwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth --level lpar " + " -F mac_addr,slot_num|grep %lld|" + " sed -e 's/^.*,//g'", mac); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, net->conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &slot_num) == -1) +goto err; + +/* excluding interface */ + +virBufferAddLit(&buf, "chhwres "); +if (system_type == HMC) +virBufferVSprintf(&buf, "-m %s ", managed_system); + +virBufferVSprintf(&buf, + " -r virtualio --rsubtype eth" + " --id %d -o r -s %d", lpar_id, slot_num); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, net->conn); + +if (exit_status < 0 || ret != NULL) +goto err; + +if (phypUUIDTable_RemNetwork(net->conn, mac) < 0) +goto err; + +VIR_FREE(cmd); +VIR_FREE(ret); +return 0; + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return -1; +} + +static virNetworkPtr +phypCreateNetwork(virConnectPtr conn, const char *
[libvirt] [PATCH 2/3] PHYP: Adding basic network functions
Now adding some basic operation network functions and its UUID "helpers". --- src/phyp/phyp_driver.c | 202 ++- src/phyp/phyp_uuid.c | 177 ++ src/phyp/phyp_uuid.h |8 ++ 3 files changed, 382 insertions(+), 5 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 6f3f49d..c44fc69 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -667,6 +667,7 @@ phypOpen(virConnectPtr conn, size_t len = 0; int internal_socket; uuid_tablePtr uuid_table = NULL; +uuid_nettablePtr uuid_nettable = NULL; phyp_driverPtr phyp_driver = NULL; char *char_ptr; char *managed_system = NULL; @@ -693,6 +694,11 @@ phypOpen(virConnectPtr conn, goto failure; } +if (VIR_ALLOC(uuid_nettable) < 0) { +virReportOOMError(); +goto failure; +} + if (VIR_ALLOC(connection_data) < 0) { virReportOOMError(); goto failure; @@ -744,10 +750,15 @@ phypOpen(virConnectPtr conn, uuid_table->nlpars = 0; uuid_table->lpars = NULL; +uuid_nettable->nnets = 0; +uuid_nettable->nets = NULL; + if (conn->uri->path) phyp_driver->managed_system = managed_system; phyp_driver->uuid_table = uuid_table; +phyp_driver->uuid_nettable = uuid_nettable; + if ((phyp_driver->caps = phypCapsInit()) == NULL) { virReportOOMError(); goto failure; @@ -759,14 +770,17 @@ phypOpen(virConnectPtr conn, if ((phyp_driver->system_type = phypGetSystemType(conn)) == -1) goto failure; -if (phypUUIDTable_Init(conn) == -1) -goto failure; - if (phyp_driver->system_type == HMC) { if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) goto failure; } +if (phypUUIDTable_Init(conn) == -1) +goto failure; + +if (phypUUIDNetworkTable_Init(conn) == -1) +goto failure; + return VIR_DRV_OPEN_SUCCESS; failure: @@ -777,6 +791,7 @@ phypOpen(virConnectPtr conn, } phypUUIDTable_Free(uuid_table); +phypUUIDNetworkTable_Free(uuid_nettable); if (session != NULL) { libssh2_session_disconnect(session, "Disconnecting..."); @@ -801,6 +816,7 @@ phypClose(virConnectPtr conn) virCapabilitiesFree(phyp_driver->caps); phypUUIDTable_Free(phyp_driver->uuid_table); +phypUUIDNetworkTable_Free(phyp_driver->uuid_nettable); VIR_FREE(phyp_driver->managed_system); VIR_FREE(phyp_driver); VIR_FREE(connection_data); @@ -2813,6 +2829,182 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags) return NULL; } +int +phypListNetworkMAC(virConnectPtr conn, long long *macs, int nnets) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +int system_type = phyp_driver->system_type; +char *managed_system = phyp_driver->managed_system; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +int got = -1; +char *cmd = NULL; +char *ret = NULL; +char *line, *next_line; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virBufferAddLit(&buf, "lshwres"); +if (system_type == HMC) +virBufferVSprintf(&buf, " -m %s", managed_system); + +virBufferVSprintf(&buf, " -r virtualio --rsubtype eth --level lpar" + "|grep -v lpar_id=%d| sed -e 's/^.*mac_addr=//g'", + vios_id); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +/* I need to parse the textual return in order to get the macs */ +line = ret; +got = 0; +while (*line && got < nnets) { +if (virStrToLong_ll(line, &next_line, 10, &macs[got]) == -1) { +VIR_ERROR(_("Cannot parse number from '%s'"), line); +got = -1; +goto err; +} +got++; +line = next_line; +while (*line == '\n') +line++; /* skip \n */ +} + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return got; +} + +int +phypListNetworks(virConnectPtr conn, char **const names, int nnames) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +int system_type = phyp_driver->system_type; +char *managed_system = phyp_driver->managed_system; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +int got = 0; +int i; +char *cmd = NULL; +char *ret = NULL; +char *networks = NULL; +char *char_ptr2 = NULL; +virBuffer buf = VIR_BUFFE
[libvirt] [PATCH 1/3] PHYP: Separating UUID functions in another file
} -uuid_table->lpars[i]->id = ids[i]; - -if (virUUIDGenerate(uuid_table->lpars[i]->uuid) < 0) -VIR_WARN("Unable to generate UUID for domain %d", - ids[i]); -} -} else { -virReportOOMError(); -goto err; -} - -if (phypUUIDTable_WriteFile(conn) == -1) -goto err; - -if (phypUUIDTable_Push(conn) == -1) -goto err; -} else { -if (phypUUIDTable_ReadFile(conn) == -1) -goto err; -goto exit; -} - - exit: -VIR_FREE(ids); -return 0; - - err: -VIR_FREE(ids); -return -1; -} - -static void -phypUUIDTable_Free(uuid_tablePtr uuid_table) -{ -int i; - -if (uuid_table == NULL) -return; - -for (i = 0; i < uuid_table->nlpars; i++) -VIR_FREE(uuid_table->lpars[i]); - -VIR_FREE(uuid_table->lpars); -VIR_FREE(uuid_table); -} - -static int escape_specialcharacters(char *src, char *dst, size_t dstlen) { size_t len = strlen(src); diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h index bc8e003..603d048 100644 --- a/src/phyp/phyp_driver.h +++ b/src/phyp/phyp_driver.h @@ -34,6 +34,7 @@ # define LPAR_EXEC_ERR -1 # define SSH_CONN_ERR -2 /* error while trying to connect to remote host */ # define SSH_CMD_ERR -3 /* error while trying to execute the remote cmd */ +# define NETNAME_SIZE 24 typedef struct _ConnectionData ConnectionData; typedef ConnectionData *ConnectionDataPtr; @@ -42,6 +43,28 @@ struct _ConnectionData { int sock; }; + +/* This is the network struct that relates + * the MAC with UUID generated by the API + * */ +typedef struct _net net_t; +typedef net_t *netPtr; +struct _net { +unsigned char uuid[VIR_UUID_BUFLEN]; +long long mac; +char name[NETNAME_SIZE]; +}; + +/* Struct that holds how many networks we're + * handling and a pointer to an array of net structs + * */ +typedef struct _uuid_nettable uuid_nettable_t; +typedef uuid_nettable_t *uuid_nettablePtr; +struct _uuid_nettable { +int nnets; +netPtr *nets; +}; + /* This is the lpar (domain) struct that relates * the ID with UUID generated by the API * */ @@ -68,6 +91,7 @@ typedef struct _phyp_driver phyp_driver_t; typedef phyp_driver_t *phyp_driverPtr; struct _phyp_driver { uuid_tablePtr uuid_table; +uuid_nettablePtr uuid_nettable; virCapsPtr caps; int vios_id; @@ -81,4 +105,21 @@ struct _phyp_driver { int phypRegister(void); + +/* + * Functions used in the phyp_uuid.c and must be visible outside phyp_driver.c + * */ +int phypNumDomainsGeneric(virConnectPtr conn, unsigned int type); + +int phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, + unsigned int type); + +int waitsocket(int socket_fd, LIBSSH2_SESSION * session); + +int phypNumOfNetworks(virConnectPtr conn); + +int phypListNetworks(virConnectPtr conn, char **const names, int nnames); + +int phypListNetworkMAC(virConnectPtr conn, long long *macs, int nnets); + #endif /* PHYP_DRIVER_H */ diff --git a/src/phyp/phyp_uuid.c b/src/phyp/phyp_uuid.c new file mode 100644 index 000..a97dd44 --- /dev/null +++ b/src/phyp/phyp_uuid.c @@ -0,0 +1,657 @@ + +/* + * Copyright (C) 2010 Red Hat, Inc. + * Copyright IBM Corp. 2010 + * + * phyp_uuid.c: set of functions to handle lpar uuid and network uuid + * which does not have uuid itself, it must be artificially + * created. + * + * Authors: + * Eduardo Otubo + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "internal.h" +#include "authhelper.h" +#include "util.h" +#include "datatypes.h" +#include "buf.h" +#include "memory.h" +#include "logging.h" +#include "driver.h" +#include "libvirt/libvirt.h" +#include "virterror_internal.h" +#include "uuid.h" +#include "domain_conf.h" +#include "storage_conf.h" +#include "nodeinfo.h" +#include
[libvirt] [PATCH 0/3] PHYP: Adding network management support
This is a series of 3 patches to add network management support for pHyp driver. Eduardo Otubo (3): PHYP: Separating UUID functions in another file PHYP: Adding basic network functions PHYP: create, destroy and other network functions po/POTFILES.in |1 + src/Makefile.am|3 +- src/phyp/phyp_driver.c | 1066 +++- src/phyp/phyp_driver.h | 43 ++- src/phyp/phyp_uuid.c | 834 + src/phyp/phyp_uuid.h | 44 ++ 6 files changed, 1520 insertions(+), 471 deletions(-) create mode 100644 src/phyp/phyp_uuid.c create mode 100644 src/phyp/phyp_uuid.h -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] PHYP: Bad comparison when checking for existing domain name
On 08/17/2010 04:04 PM, Eduardo Otubo wrote: When creating a new domain from an XML, the check for an existing domain name should compare the return of the function to a a valid LPAR ID (!= -1) and not to error (== -1). --- src/phyp/phyp_driver.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 25d..8eeba73 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3759,7 +3759,7 @@ phypDomainCreateAndStart(virConnectPtr conn, goto err; /* checking if this name already exists on this system */ -if (phypGetLparID(session, managed_system, def->name, conn) == -1) { +if (phypGetLparID(session, managed_system, def->name, conn) != -1) { VIR_WARN0("LPAR name already exists."); goto err; } Any comments on this? I would be glad! Thanks, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv3] PHYP: Checking for NULL values when building new guest
When creating a new gust, the function phypBuildLpar() was not checking for NULL values, making the driver to have a segmentation fault. --- src/phyp/phyp_driver.c | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 25d..fcbb15e 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3701,6 +3701,29 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) int exit_status = 0; virBuffer buf = VIR_BUFFER_INITIALIZER; +if (!def->memory) { +PHYP_ERROR(VIR_ERR_XML_ERROR,"%s", +_("Field \"\" on the domain XML file is missing or has " +"invalid value.")); +goto err; +} + +if (!def->maxmem) { +PHYP_ERROR(VIR_ERR_XML_ERROR,"%s", +_("Field \"\" on the domain XML file is missing or" +" has invalid value.")); +goto err; +} + +if (def->ndisks > 0) { +if (!def->disks[0]->src) { +PHYP_ERROR(VIR_ERR_XML_ERROR,"%s", +_("Field \"\" under \"\" on the domain XML file is " +"missing.")); +goto err; +} +} + virBufferAddLit(&buf, "mksyscfg"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] PHYP: Checking for NULL values when building new guest
memory and maxmem might be 0 when the user sets the to 0 in the domain XML. IMHO comparing> 0 is cleaner here. I already submitted the patch v2 with this fix and I didn't understand exactly this comparison > 0. Memory should be greater than zero, right? Hence, if memory < 0, then ERROR. Right? If not, could you explain the reasons? Thanks, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv2] PHYP: Checking for NULL values when building new guest
I fixed the way I check for invalid values and changed the way I report errors (from VIR_ERROR0 to PHYP_ERROR). I'll change the VIR_WARNs in another different patch. --- src/phyp/phyp_driver.c | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 25d..a74eedf 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3701,6 +3701,29 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) int exit_status = 0; virBuffer buf = VIR_BUFFER_INITIALIZER; +if (def->memory > 0) { +PHYP_ERROR(VIR_ERR_XML_ERROR,"%s", +_("Field \"\" on the domain XML file is missing or has " +"invalid value.")); +goto err; +} + +if (def->maxmem > 0) { +PHYP_ERROR(VIR_ERR_XML_ERROR,"%s", +_("Field \"\" on the domain XML file is missing or" +" has invalid value.")); +goto err; +} + +if (def->ndisks > 0) { +if (!def->disks[0]->src) { +PHYP_ERROR(VIR_ERR_XML_ERROR,"%s", +_("Field \"\" under \"\" on the domain XML file is " +"missing.")); +goto err; +} +} + virBufferAddLit(&buf, "mksyscfg"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] PHYP: Checking for NULL values when building new guest
When creating a new gust, the function phypBuildLpar() was not checking for NULL values, making the driver to have a segmentation fault. --- src/phyp/phyp_driver.c | 19 +++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 25d..999870e 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3701,6 +3701,25 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) int exit_status = 0; virBuffer buf = VIR_BUFFER_INITIALIZER; +if (!def->name) { +VIR_ERROR0(_("Field \"\" on the domain XML file missing.")); +goto err; +} else if (!def->memory) { +VIR_ERROR0(_ + ("Field \"\" on the domain XML file missing.")); +goto err; +} else if (!def->maxmem) { +VIR_ERROR0(_ + ("Field \"\" on the domain XML file missing.")); +goto err; +} else if (!def->vcpus) { +VIR_ERROR0(_("Field \"\" on the domain XML file missing.")); +goto err; +} else if (!def->disks[0]->src) { +VIR_ERROR0(_("Field \"\" on the domain XML file missing.")); +goto err; +} + virBufferAddLit(&buf, "mksyscfg"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] PHYP: Bad comparison when checking for existing domain name
When creating a new domain from an XML, the check for an existing domain name should compare the return of the function to a a valid LPAR ID (!= -1) and not to error (== -1). --- src/phyp/phyp_driver.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 25d..8eeba73 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3759,7 +3759,7 @@ phypDomainCreateAndStart(virConnectPtr conn, goto err; /* checking if this name already exists on this system */ -if (phypGetLparID(session, managed_system, def->name, conn) == -1) { +if (phypGetLparID(session, managed_system, def->name, conn) != -1) { VIR_WARN0("LPAR name already exists."); goto err; } -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] PHYP: Add rudimentary network driver
I changed virStorage[Open|Close] to virVIOSDriver[Open|Close] so the network driver can use it - since the network driver deals with Open/Close in the same way. --- src/phyp/phyp_driver.c | 33 + 1 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index aa4722e..975d941 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3864,7 +3864,7 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) } static virDrvOpenStatus -phypStorageOpen(virConnectPtr conn, +phypVIOSDriverOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, int flags) { @@ -3877,7 +3877,7 @@ phypStorageOpen(virConnectPtr conn, } static int -phypStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) +phypVIOSDriverClose(virConnectPtr conn ATTRIBUTE_UNUSED) { return 0; } @@ -3984,8 +3984,8 @@ static virDriver phypDriver = { static virStorageDriver phypStorageDriver = { .name = "PHYP", -.open = phypStorageOpen, -.close = phypStorageClose, +.open = phypVIOSDriverOpen, +.close = phypVIOSDriverClose, .numOfPools = phypNumOfStoragePools, .listPools = phypListStoragePools, @@ -4023,6 +4023,29 @@ static virStorageDriver phypStorageDriver = { .poolIsPersistent = NULL }; +static virNetworkDriver phypNetworkDriver = { +.name = "PHYP", +.open = phypVIOSDriverOpen, +.close = phypVIOSDriverClose, +.numOfNetworks = NULL, +.listNetworks = NULL, +.numOfDefinedNetworks = NULL, +.listDefinedNetworks = NULL, +.networkLookupByUUID = NULL, +.networkLookupByName = NULL, +.networkCreateXML = NULL, +.networkDefineXML = NULL, +.networkUndefine = NULL, +.networkCreate = NULL, +.networkDestroy = NULL, +.networkDumpXML = NULL, +.networkGetBridgeName = NULL, +.networkGetAutostart = NULL, +.networkSetAutostart = NULL, +.networkIsActive = NULL, +.networkIsPersistent = NULL +}; + int phypRegister(void) { @@ -4030,6 +4053,8 @@ phypRegister(void) return -1; if (virRegisterStorageDriver(&phypStorageDriver) < 0) return -1; +if (virRegisterNetworkDriver(&phypNetworkDriver) < 0) +return -1; return 0; } -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] phyp: Fixing possible buffer overflow
On 08/05/2010 04:04 PM, Laine Stump wrote: On 08/04/2010 03:00 PM, Eduardo Otubo wrote: Hello Laine, It's been quite a while since we had this discussion about my patch. Sorry about the delay on replaying, I had a congress and I've been sick in the last couple of days. Now going back to work. :-) (this new patch is corrupt and doesn't apply. Not sure how you sent it, but I'm guessing your mailer mangled it. It's usually better to only send patches with git send-email, or to attach the output of git format-patch to the mail, rather than pasting it inline) I don't know what happened, I always send patches using git send-email. I'll recheck next times. Thanks. This version is closer *in location* to avoiding the overflow, but it's still comparing the wrong index - it's looking at the index into the full array (ret, ie "i") rather than into the small copy that is used to convert (id_c, ie "j"). Also, it still allows writing past the end of the array (i == j == 4, so it can write to id_c[4]). Even allowing a write to id_c[3] would be a problem, since that would overwrite the terminating NULL, thus creating the possibility that virStrToLong_i could overrun the end of the array (or, if virStrToLong_i fails, the VIR_ERROR following it would try to print a string that is not NULL terminated - a *much* worse prospect). Additionally the 2nd occurence of "memset(id_c, 0, 10)" inside the loop that I noted in my last mail has been left unchanged (and this memset will be done every time the function is called, even if there is no overflow of string length, so it is *guaranteed* the buffer will be overflowed). Finally, in the case that the output of the exec is too long, this new patch will simply exit from the loop early and return success, rather than logging an error and returning failure. These problems *could* be fixed by 1) changing "i <= 4" to "j < 3", 2) fixing the 2nd memset to clear 4 bytes instead of 10, and 3) turning the case of "j >= 3" into an error instead of just exiting the loop. However... did you look at the counter-proposed patch in my previous email? I'm assuming that either you didn't notice it, or that you're trying to come up with a patch that makes the fewest changes possible while fixing the perceived bug. I think that patch would be a better idea for several reasons, and as long as we're fixing this function, we may as well fix it in the best way possible. I just saw your patch now, seem reasonable. I understand your points and I believe your patch fixes the bug pretty well. Applied here, compiled and run with some tests, seems pretty ack for me. I just want to verify: you applied the patch from my mail with 0 changes, and built/tested with that, correct? Yes, applied your patch with no changes to a clean branch. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] phyp: Fixing possible buffer overflow
Hello Laine, It's been quite a while since we had this discussion about my patch. Sorry about the delay on replaying, I had a congress and I've been sick in the last couple of days. Now going back to work. :-) (this new patch is corrupt and doesn't apply. Not sure how you sent it, but I'm guessing your mailer mangled it. It's usually better to only send patches with git send-email, or to attach the output of git format-patch to the mail, rather than pasting it inline) I don't know what happened, I always send patches using git send-email. I'll recheck next times. Thanks. This version is closer *in location* to avoiding the overflow, but it's still comparing the wrong index - it's looking at the index into the full array (ret, ie "i") rather than into the small copy that is used to convert (id_c, ie "j"). Also, it still allows writing past the end of the array (i == j == 4, so it can write to id_c[4]). Even allowing a write to id_c[3] would be a problem, since that would overwrite the terminating NULL, thus creating the possibility that virStrToLong_i could overrun the end of the array (or, if virStrToLong_i fails, the VIR_ERROR following it would try to print a string that is not NULL terminated - a *much* worse prospect). Additionally the 2nd occurence of "memset(id_c, 0, 10)" inside the loop that I noted in my last mail has been left unchanged (and this memset will be done every time the function is called, even if there is no overflow of string length, so it is *guaranteed* the buffer will be overflowed). Finally, in the case that the output of the exec is too long, this new patch will simply exit from the loop early and return success, rather than logging an error and returning failure. These problems *could* be fixed by 1) changing "i <= 4" to "j < 3", 2) fixing the 2nd memset to clear 4 bytes instead of 10, and 3) turning the case of "j >= 3" into an error instead of just exiting the loop. However... did you look at the counter-proposed patch in my previous email? I'm assuming that either you didn't notice it, or that you're trying to come up with a patch that makes the fewest changes possible while fixing the perceived bug. I think that patch would be a better idea for several reasons, and as long as we're fixing this function, we may as well fix it in the best way possible. I just saw your patch now, seem reasonable. I understand your points and I believe your patch fixes the bug pretty well. Applied here, compiled and run with some tests, seems pretty ack for me. Thanks for the help :-) -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Slides for FISL presentation
On 07/16/2010 04:22 AM, Eduardo Otubo wrote: Hello all, This is the first draft for my presentation at FISL. I would like you to take a look and give your opinions. Any comment is always welcome :-) Thank you! https://docs.google.com/leaf?id=0B67FxRV5aa7_YWI4YzQ2MWQtZWQwYi00NjE0LWEyZDItNDI3ZDhiZmJkMWNi&hl=en ps.: I didn't know where to put the file, I hosted at google docs and made it public. You all should be able to download it. Any issues, please let me know. Thanks again. Oops, trigger happy here, this is the link of the correct presentation. https://docs.google.com/leaf?id=0B67FxRV5aa7_NGIxOWUxODEtNDA1Yy00ZjllLTgzNWUtMGVlZjMwODUwYjll&hl=en Cheers! -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC] Slides for FISL presentation
Hello all, This is the first draft for my presentation at FISL. I would like you to take a look and give your opinions. Any comment is always welcome :-) Thank you! https://docs.google.com/leaf?id=0B67FxRV5aa7_YWI4YzQ2MWQtZWQwYi00NjE0LWEyZDItNDI3ZDhiZmJkMWNi&hl=en ps.: I didn't know where to put the file, I hosted at google docs and made it public. You all should be able to download it. Any issues, please let me know. Thanks again. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] phyp: Fixing possible buffer overflow
On 07/15/2010 11:01 PM, Laine Stump wrote: On 07/15/2010 06:37 PM, Eduardo Otubo wrote: The line src/phyp/phyp_driver.c:427 was crashing by buffer overflow if the return of the command wasn't<=10. The highest number for a LPAR ID is 256 per machine, no need to allocate 10 bytes for it. So, adjusting the correct size (+1 byte for the '\n') and checking for errors. This analysis doesn't make sense to me. On the one hand, you say that the function was crashing if the return from the command wasn't<= 10 bytes long (implying that it sometimes was longer), on the other hand, you say that part of the solution is to change the code to only handle 4 bytes (you forgot about the trailing NULL there, BTW - should have been 3), because you'll never get more than that. I'm sorry. My bad here. The lssyscfg (with the correct parameters and greps) will return something like this: 5 4 6 7 10 1 143 These are the LPAR IDs. Each line cannot be bigger than 3 characters (+1 for '\n'). So, I just allocate 4 bytes to hold these values, one at a time and memset it with zeros. If there's an error, there will be a single line with the error message, like this one: "HSCL8018 The managed system rico was not found." IMO the best choice is to loop in the result and if I can't find a '\n' after 3 character, I return an error. My mistake was to check the entire string returned from exec. My bad, sorry. I think this patch is much clearer on what the problem is. Thanks for the comments! --- src/phyp/phyp_driver.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ee1e21b..0c50c9a 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -383,7 +383,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, int got = 0; char *char_ptr; unsigned int i = 0, j = 0; -char id_c[10]; +char id_c[4]; char *cmd = NULL; char *ret = NULL; const char *state; @@ -394,7 +394,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, else state = " "; -memset(id_c, 0, 10); +memset(id_c, 0, 4); virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) @@ -414,7 +414,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, if (exit_status < 0 || ret == NULL) goto err; else { -while (got < nids) { +while (got < nids && i <= 4) { if (ret[i] == '\0') break; else if (ret[i] == '\n') { -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] phyp: Fixing possible buffer overflow
The line src/phyp/phyp_driver.c:427 was crashing by buffer overflow if the return of the command wasn't <=10. The highest number for a LPAR ID is 256 per machine, no need to allocate 10 bytes for it. So, adjusting the correct size (+1 byte for the '\n') and checking for errors. --- src/phyp/phyp_driver.c |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ee1e21b..f8fd29b 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -383,7 +383,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, int got = 0; char *char_ptr; unsigned int i = 0, j = 0; -char id_c[10]; +char id_c[4]; char *cmd = NULL; char *ret = NULL; const char *state; @@ -394,7 +394,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, else state = " "; -memset(id_c, 0, 10); +memset(id_c, 0, 4); virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) @@ -410,6 +410,11 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, ret = phypExec(session, cmd, &exit_status, conn); +if (strlen(ret) > 4) { +VIR_ERROR0(ret); +goto err; +} + /* I need to parse the textual return in order to get the ret */ if (exit_status < 0 || ret == NULL) goto err; -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv3 4/4] phyp: optimize use of sed
On 06/24/2010 07:32 PM, Eric Blake wrote: Minor speedups by using the full power of sed. * src/phyp/phyp_driver.c (phypGetVIOSFreeSCSIAdapter) (phypDiskType, phypListDefinedDomains): Use fewer processes, by folding other work into sed. (phypGetVIOSPartitionID): Likewise. Also avoid non-portable use of 'sed -s'. --- src/phyp/phyp_driver.c | 12 ++-- 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index df6d10c..3692f2c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -227,8 +227,8 @@ phypGetVIOSPartitionID(virConnectPtr conn) virBufferAddLit(&buf, "lssyscfg"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferAddLit(&buf, " -r lpar -F lpar_id,lpar_env|grep " -"vioserver|sed -s 's/,.*$//'"); +virBufferAddLit(&buf, " -r lpar -F lpar_id,lpar_env" +"|sed -n '/vioserver/ {\n s/,.*$//\n p\n}'"); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); @@ -1889,7 +1889,7 @@ phypGetVIOSFreeSCSIAdapter(virConnectPtr conn) if (system_type == HMC) virBufferAddChar(&buf, '\''); -virBufferVSprintf(&buf, "|grep -v ',[^.*]'|head -n 1|sed -e 's/,//g'"); +virBufferVSprintf(&buf, "|sed '/,[^.*]/d; s/,//g; q'"); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); @@ -3330,7 +3330,7 @@ phypDiskType(virConnectPtr conn, char *backing_device) if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); virBufferVSprintf(&buf, " -p %d -c \"lssp -field name type " - "-fmt , -all|grep %s|sed -e 's/^.*,//'\"", + "-fmt , -all|sed -n '/%s/ {\n s/^.*,//\n p\n}'\"", vios_id, backing_device); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); @@ -3398,8 +3398,8 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames) virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -F name,state | grep \"Not Activated\" | " - "sed -e 's/,.*$//'"); +virBufferVSprintf(&buf, " -F name,state" + "|sed -n '/Not Activated/ {\n s/,.*$//\n p\n}'"); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); I tested each sed expression on HMC shell, all of them are working fine. Eric, again, thank you very much for all the help to complete this driver. It's been a great lesson to discuss all these patches. I Hope I can improve the quality of them in the future. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv3 3/4] phyp: add storage management driver
On 06/24/2010 07:32 PM, Eric Blake wrote: From: Eduardo Otubo Add the storage management driver to the Power Hypervisor driver. This is a big but simple patch, it's just a new set of functions. This patch includes: * Storage driver: The set of pool-* and vol-* functions. * attach-disk function. * Support for IVM on the new functions. Signed-off-by: Eric Blake --- This is more or less Eduardo's v2 2/2 patch, but reorganized in topological order and converted to static functions, and with a lot of cleanups (such as from v2 1/2) squashed in. I tested that it compiles, but I did _not_ test that it works for HVM - Eduardo, you'll need to give this a once-over. I tested all the new functions and they are working properly on the HMC/VIOs and IVM. ACK. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv3 2/4] phyp: add rudimentary storage driver
On 06/24/2010 07:32 PM, Eric Blake wrote: From: Eduardo Otubo * src/phyp/phyp_driver.c (phypStorageDriver): New driver. (phypStorageOpen, phypStorageClose): New functions. (phypRegister): Register it. Signed-off-by: Eric Blake --- For my sanity, I split out the creation/registration of the driver from the addition of all the methods in the driver. src/phyp/phyp_driver.c | 64 +++- 1 files changed, 63 insertions(+), 1 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 0912f90..341ee99 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -56,6 +56,7 @@ #include "virterror_internal.h" #include "uuid.h" #include "domain_conf.h" +#include "storage_conf.h" #include "nodeinfo.h" #include "phyp_driver.h" @@ -2265,6 +2266,22 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) } +static virDrvOpenStatus +phypStorageOpen(virConnectPtr conn ATTRIBUTE_UNUSED, +virConnectAuthPtr auth ATTRIBUTE_UNUSED, +int flags) +{ +virCheckFlags(0, VIR_DRV_OPEN_ERROR); + +return VIR_DRV_OPEN_SUCCESS; +} + +static int +phypStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ +return 0; +} + static virDriver phypDriver = { VIR_DRV_PHYP, "PHYP", phypOpen, /* open */ phypClose, /* close */ @@ -2364,9 +2381,54 @@ static virDriver phypDriver = { NULL, /* domainSnapshotDelete */ }; +static virStorageDriver phypStorageDriver = { +.name = "PHYP", +.open = phypStorageOpen, +.close = phypStorageClose, + +.numOfPools = NULL, +.listPools = NULL, +.numOfDefinedPools = NULL, +.listDefinedPools = NULL, +.findPoolSources = NULL, +.poolLookupByName = NULL, +.poolLookupByUUID = NULL, +.poolLookupByVolume = NULL, +.poolCreateXML = NULL, +.poolDefineXML = NULL, +.poolBuild = NULL, +.poolUndefine = NULL, +.poolCreate = NULL, +.poolDestroy = NULL, +.poolDelete = NULL, +.poolRefresh = NULL, +.poolGetInfo = NULL, +.poolGetXMLDesc = NULL, +.poolGetAutostart = NULL, +.poolSetAutostart = NULL, +.poolNumOfVolumes = NULL, +.poolListVolumes = NULL, + +.volLookupByName = NULL, +.volLookupByKey = NULL, +.volLookupByPath = NULL, +.volCreateXML = NULL, +.volCreateXMLFrom = NULL, +.volDelete = NULL, +.volGetInfo = NULL, +.volGetXMLDesc = NULL, +.volGetPath = NULL, +.poolIsActive = NULL, +.poolIsPersistent = NULL +}; + int phypRegister(void) { -virRegisterDriver(&phypDriver); +if (virRegisterDriver(&phypDriver)< 0) +return -1; +if (virRegisterStorageDriver(&phypStorageDriver)< 0) +return -1; + return 0; } ACK. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv3 1/4] phyp: reduce scope of driver functions
On 06/24/2010 07:32 PM, Eric Blake wrote: Several phyp functions are not namespace clean, and had no reason to be exported since no one outside the phyp driver needed to use them. Rather than do lots of forward declarations, I was able to topologically sort the file. So, this patch looks huge, but is really just a matter of marking things static and dealing with the compiler fallout. * src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard. (phypCheckSPFreeSapce): Delete unused declaration. (phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit) (phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile) (phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull) (phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free) (escape_specialcharacters, waitsocket, phypGetLparUUID) (phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric) (phypGetRemoteSlot, phypGetBackingDevice, phypDiskType) (openSSHSession): Move declarations to phyp_driver.c and make static. * src/phyp/phyp_driver.c: Rearrange file contents to provide topological sorting of newly-static funtions (no semantic changes other than reduced scope). (phypGetBackingDevice, phypDiskType): Mark unused, for now. --- New patch - reduce scope where possible, and rearrange everything into topological order. There is no significant code changes beyond marking a few things 'static', so although it looks big, you don't have to worry about the guts of any command changing. Yes, I was aware of that and was planning a future patch with these changes. If you thought that would be better to clean these up early it's ok too. Thank you very much. The patch seems ok. I tested the commands with my HMC/VIOS and IVM and everything is still working. Thanks. ACK. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] Adding Storage Management driver (semantic changes)
This is the first patch, just over the semantic changes over the code itself. Added the whole storage management stack and fixed the echo $(( expr)) to just increment the variable in the return of the function. Hope we can get it acknowledged in time for the next release :) Thanks for all the comments so far! --- src/phyp/phyp_driver.c | 1683 +++- src/phyp/phyp_driver.h | 51 ++ 2 files changed, 1731 insertions(+), 3 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index cefb8be..51bab2c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -56,6 +56,7 @@ #include "virterror_internal.h" #include "uuid.h" #include "domain_conf.h" +#include "storage_conf.h" #include "nodeinfo.h" #include "phyp_driver.h" @@ -1680,6 +1681,484 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) } +static char * +phypGetLparProfile(virConnectPtr conn, int lpar_id) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +char *cmd = NULL; +char *ret = NULL; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virBufferAddLit(&buf, "lssyscfg"); +if (system_type == HMC) +virBufferVSprintf(&buf, " -m %s ", managed_system); +virBufferVSprintf(&buf, + " -r prof --filter lpar_ids=%d -F name|head -n 1", + lpar_id); +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return NULL; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +char *char_ptr = strchr(ret, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +VIR_FREE(cmd); +return ret; + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return NULL; +} + +static int +phypGetVIOSNextSlotNumber(virConnectPtr conn) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; +char *profile = NULL; +int slot = 0; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +if (!(profile = phypGetLparProfile(conn, vios_id))) { +VIR_ERROR("%s", "Unable to get VIOS profile name."); +goto err; +} + +virBufferAddLit(&buf, "lssyscfg"); + +if (system_type == HMC) +virBufferVSprintf(&buf, " -m %s ", managed_system); + +virBufferVSprintf(&buf, "-r prof --filter " + "profile_names=%s -F virtual_eth_adapters," + "virtual_opti_pool_id,virtual_scsi_adapters," + "virtual_serial_adapters|sed -e 's/\"//g' -e " + "'s/,/\\n/g'|sed -e 's/\\(^[0-9][0-9]\\*\\).*$/\\1/'" + "|sort|tail -n 1", profile); + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} + +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &slot) == -1) +goto err; + +VIR_FREE(cmd); +VIR_FREE(ret); +return ++slot; + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return -1; +} + +static int +phypCreateServerSCSIAdapter(virConnectPtr conn) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +char *cmd = NULL; +char *ret = NULL; +char *profile = NULL; +int slot = 0; +char *vios_name = NULL; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +if (! +(vios_name = + phypGetLparNAME(session, managed_system, vios_id, conn))) { +VIR_ERROR("%s", "Unable to get VIOS name"); +goto err; +} + +if (!(profile = phypGetLparProfile(conn, vios_id))) { +VIR_ERROR("%s", "Unable to get VIOS profile name."); +goto err; +} + +if ((slot = phypGetVIOSNextSlotNumber(conn)) == -1) { +VIR_ERROR("%s", "Unable to get free slot number"); +goto err; +} + +/* Listing all the virtual_scsi_adapter interfaces, the new a
[libvirt] [PATCH 2/2] Adding Storage Management driver (style and indentation)
This is just the indentation, style and cleanup patch. --- src/phyp/phyp_driver.c | 100 +++ src/phyp/phyp_driver.h | 13 -- 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 51bab2c..7e39dfd 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -656,7 +656,8 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, virBufferAddLit(&buf, "lshwres"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -r mem --level lpar -F %s --filter lpar_ids=%d", +virBufferVSprintf(&buf, + " -r mem --level lpar -F %s --filter lpar_ids=%d", type ? "curr_mem" : "curr_max_mem", lpar_id); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); @@ -722,7 +723,8 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, virBufferAddLit(&buf, "lshwres"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -r proc --level lpar -F %s --filter lpar_ids=%d", +virBufferVSprintf(&buf, + " -r proc --level lpar -F %s --filter lpar_ids=%d", type ? "curr_max_procs" : "curr_procs", lpar_id); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); @@ -773,8 +775,7 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system, if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); virBufferVSprintf(&buf, " -r virtualio --rsubtype scsi -F " - "remote_slot_num --filter lpar_names=%s", - lpar_name); + "remote_slot_num --filter lpar_names=%s", lpar_name); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); @@ -1067,7 +1068,8 @@ phypNumDomainsGeneric(virConnectPtr conn, unsigned int type) virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -F lpar_id,state %s |grep -c '^[0-9]*'", state); +virBufferVSprintf(&buf, " -F lpar_id,state %s |grep -c '^[0-9]*'", + state); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); @@ -1141,7 +1143,8 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -F lpar_id,state %s | sed -e 's/,.*$//'", state); +virBufferVSprintf(&buf, " -F lpar_id,state %s | sed -e 's/,.*$//'", + state); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); @@ -1744,7 +1747,7 @@ phypGetVIOSNextSlotNumber(virConnectPtr conn) virBuffer buf = VIR_BUFFER_INITIALIZER; if (!(profile = phypGetLparProfile(conn, vios_id))) { -VIR_ERROR("%s", "Unable to get VIOS profile name."); +VIR_ERROR0(_("Unable to get VIOS profile name.")); goto err; } @@ -1806,17 +1809,17 @@ phypCreateServerSCSIAdapter(virConnectPtr conn) if (! (vios_name = phypGetLparNAME(session, managed_system, vios_id, conn))) { -VIR_ERROR("%s", "Unable to get VIOS name"); +VIR_ERROR0(_("Unable to get VIOS name")); goto err; } if (!(profile = phypGetLparProfile(conn, vios_id))) { -VIR_ERROR("%s", "Unable to get VIOS profile name."); +VIR_ERROR0(_("Unable to get VIOS profile name.")); goto err; } if ((slot = phypGetVIOSNextSlotNumber(conn)) == -1) { -VIR_ERROR("%s", "Unable to get free slot number"); +VIR_ERROR0(_("Unable to get free slot number")); goto err; } @@ -2001,7 +2004,7 @@ phypAttachDevice(virDomainPtr domain, const char *xml) if (! (vios_name = phypGetLparNAME(session, managed_system, vios_id, conn))) { -VIR_ERROR("%s", "Unable to get VIOS name"); +VIR_ERROR0(_("Unable to get VIOS name")); goto err; } @@ -2011,11 +2014,11 @@ phypAttachDevice(virDomainPtr domain, const char *xml) /* If not found, let's create one. * */ if (phypCreateServerSCSIAdapter(conn) == -1) { -VIR_ERROR("%s", "Unable to create new virtual adapter"); +VIR_ERROR0(_("Unable to create new virtual adapter")); goto err; } else { if (!(scsi_adapter = phypGetVIOSFreeSCSIAdapter(conn))) { -VIR_ERROR("%s", "Unable to create new virtual adapter"); +VIR_ERROR0(_("Unable to create new virtual adapter")); goto err; }
Re: [libvirt] [PATCH] phyp: Adding Storage Management driver (comments fixed)
virBufferVSprintf(&buf, "-r prof --filter " "profile_names=%s -F virtual_eth_adapters," "virtual_opti_pool_id,virtual_scsi_adapters," "virtual_serial_adapters|sed -e 's/\"//g' -e " "'s/,/\\n/g'|sed -e 's/\\(^[0-9][0-9]\\*\\).*$/\\1/'" - "|sort|tail -n 1` +1 ))", profile); + "|sort|tail -n 1|sed -s 's/^[0]//'` +1 ))", profile); Here's the first real meat I found in the patch (70 lines in!), but it still has an issue - you are only stripping one, instead of all, leading zeroes. I still think that doing the conversion to int, then the +1 operation, in C, will be much better than trying to do it in shell with $(()). Ok I'll fix that. My quick glance at spot checks in the rest of the file did see that you are making progress; you did incorporate what looks like quite a few of my comments. However, I did not complete my review this time around because of the mix of multiple changes in one patch. On the other hand, I agree that this still seems like something worth getting in 0.8.2 if we can clean it up fast enough. Do you need any help separating the patch into separate stages? I'll separate the identation from the semantic code right away. Thanks for the suggestion :) -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] phyp: Adding Storage Management driver (comments fixed)
All the comments from the previous email from Eric Blake are now fixed. Also fixed some styling by using indent on the whole file. Hope we can get this patch pushed to 0.8.2. Any additional comments are always welcome. []'s --- src/phyp/phyp_driver.c | 395 +++- src/phyp/phyp_driver.h | 23 ++-- 2 files changed, 239 insertions(+), 179 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 77a74ef..f39c8fb 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -656,7 +656,8 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, virBufferAddLit(&buf, "lshwres"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -r mem --level lpar -F %s --filter lpar_ids=%d", +virBufferVSprintf(&buf, + " -r mem --level lpar -F %s --filter lpar_ids=%d", type ? "curr_mem" : "curr_max_mem", lpar_id); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); @@ -722,7 +723,8 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, virBufferAddLit(&buf, "lshwres"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -r proc --level lpar -F %s --filter lpar_ids=%d", +virBufferVSprintf(&buf, + " -r proc --level lpar -F %s --filter lpar_ids=%d", type ? "curr_max_procs" : "curr_procs", lpar_id); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); @@ -773,8 +775,7 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system, if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); virBufferVSprintf(&buf, " -r virtualio --rsubtype scsi -F " - "remote_slot_num --filter lpar_names=%s", - lpar_name); + "remote_slot_num --filter lpar_names=%s", lpar_name); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); @@ -1067,7 +1068,8 @@ phypNumDomainsGeneric(virConnectPtr conn, unsigned int type) virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -F lpar_id,state %s |grep -c '^[0-9]*'", state); +virBufferVSprintf(&buf, " -F lpar_id,state %s |grep -c '^[0-9]*'", + state); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); @@ -1141,7 +1143,8 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) virBufferVSprintf(&buf, " -m %s", managed_system); -virBufferVSprintf(&buf, " -F lpar_id,state %s | sed -e 's/,.*$//'", state); +virBufferVSprintf(&buf, " -F lpar_id,state %s | sed -e 's/,.*$//'", + state); if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); @@ -1744,24 +1747,28 @@ phypGetVIOSNextSlotNumber(virConnectPtr conn) virBuffer buf = VIR_BUFFER_INITIALIZER; if (!(profile = phypGetLparProfile(conn, vios_id))) { -VIR_ERROR("%s", "Unable to get VIOS profile name."); +VIR_ERROR0(_("Unable to get VIOS profile name.")); goto err; } virBufferAddLit(&buf, "echo $((`lssyscfg"); + if (system_type == HMC) virBufferVSprintf(&buf, " -m %s ", managed_system); + virBufferVSprintf(&buf, "-r prof --filter " "profile_names=%s -F virtual_eth_adapters," "virtual_opti_pool_id,virtual_scsi_adapters," "virtual_serial_adapters|sed -e 's/\"//g' -e " "'s/,/\\n/g'|sed -e 's/\\(^[0-9][0-9]\\*\\).*$/\\1/'" - "|sort|tail -n 1` +1 ))", profile); + "|sort|tail -n 1|sed -s 's/^[0]//'` +1 ))", profile); + if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); virReportOOMError(); return -1; } + cmd = virBufferContentAndReset(&buf); ret = phypExec(session, cmd, &exit_status, conn); @@ -1802,17 +1809,17 @@ phypCreateServerSCSIAdapter(virConnectPtr conn) if (! (vios_name = phypGetLparNAME(session, managed_system, vios_id, conn))) { -VIR_ERROR("%s", "Unable to get VIOS name"); +VIR_ERROR0(_("Unable to get VIOS name")); goto err; } if (!(profile = phypGetLparProfile(conn, vios_id))) { -VIR_ERROR("%s", "Unable to get VIOS profile name."); +VIR_ERROR0(_("Unable to get VIOS profile name.")); goto err; } if ((slot = phypGetVIOSNextSlotNumber(conn)) == -1) { -VIR_ERROR("%s", "Unable to get free slot number"); +VIR_
Re: [libvirt] [PATCH] phyp: Adding storage management driver
On 06/21/2010 05:05 PM, Eric Blake wrote: On 06/21/2010 12:32 PM, Eduardo Otubo wrote: Ouch. If the result of the `` command substitution begins with 0, you have a problem with octal numbers. Remember, $((010 + 1)) is not the same as $((10 + 1)). Perhaps you can modify the sed commands used in your script to strip leading 0? Yes, I can strip the leading zero using sed, but I hardly believe that would be a such a return. But better fix this now than in the client screen. :) And, rather than doing $(()) (or expr) to do +1 in the shell, where you have to worry about octal in the first place, why not just output the last value as-is (that is, drop "echo $((`" and "` +1 ))" from cmd), then do +1 in C code? This is an option, but I really like to isolate the most I can on the shell side, returning the final value for the function. I've been keeping this pattern over all the code, so did the same here I would much rather see it shift in the other direction - do as LITTLE work in shell as possible (since you have to carefully audit for exploits, and because it is SO expensive to fork processes), and as MUCH work in C as possible. Shortcuts like 'cmd | head -n 1' => C processing are one of the few things where doing more in shell can actually be faster, as it can lead to much less I/O, and even stop a cmd with lots of output early (due to EPIPE/SIGPIPE) rather than wasting processing power in running cmd to completion when we only need the first line in C code. But anything as complex as massaging octal strings into known binary is going to be orders of magnitude faster in C than in shell. Yes, you're right on this point. I was just thinking on the easy side for the one who writes the code. Parsing strings in C is not exactly an easy job, mainly if you have all the facilities of a shell script on hand. This surely will be a separate patch in the future. Also, '\ ' is not a portable sed escape sequence. Did you mean to use the C string "s/ //g" for the shell line 's/\\ //g', in order to delete backslash-space sequences from the output? (multiple instances of this pattern in your patch) No, I meant to use the C string 's/\\ //g' for the shell line 's/\ //g' in order to delete white spaces. But that's my point. Some versions of sed treat '\ ' as the single byte space, while others treat it as the two-byte sequence backslash-space. In short: sed 's/\ //g' _is not portable_. The only portable shell command lines for deleting spaces are: sed 's/ //g' sed s/\ //g That is, either quote the space using '' in shell, or quote the space using \ in shell, but do NOT escape the space for sed. Save a process: ...|sed '1d'|sed '1d' is equivalent to: ...|sed 2d Ok, fixed. The next patch is right away. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] phyp: Adding storage management driver
ot;, + managed_system, vios_id); +virBufferVSprintf(&buf, "'lslv %s -field vgname'", volname); +} else { +virBufferVSprintf(&buf, "lslv %s -field vgname", volname); +} +virBufferVSprintf(&buf, + "|sed -e 's/^VOLUME\\ GROUP://g' -e 's/\\ //g'"); Another instance of a non-portable sed escape '\ '. But this time, I see enough context that it looks like you are trying to just delete spaces (and not backslash-space sequences). In which case, use either: shell: ...|sed -e s/\^VOLUME\ GROUP://g -e... C-string: "...|sed -e s/\\^VOLUME\\ GROUP://g -e..." or shell: ...|sed -e 's/^VOLUME GROUP://g' -e... C-string: "...|sed -e '/^VOLUME GROUP://g' -e..." I choose the first one, just get all calls in the same pattern. +char * +phypVolumeGetXMLDesc(virStorageVolPtr vol, + unsigned int flags ATTRIBUTE_UNUSED) +{ +virStorageVolDef voldef; +memset(&voldef, 0, sizeof(virStorageVolDef)); Another place for virCheckFlags(0, NULL) + +if (memmove(pool.uuid, sp->uuid, VIR_UUID_BUFLEN) == NULL) { memcpy + +virStorageVolPtr +phypVolumeLookupByName(virStoragePoolPtr pool, const char *volname) +{ + +char key[PATH_MAX]; Stack-allocating PATH_MAX bytes is just as non-portable as malloc'ing that many bytes; but here, you've got precedence in existing libvirt source (ultimately, I mean to sweep the source code to clean that all up). Are you sure we don't have a better bound on the maximum key length? And actually, looking at src/datatypes.c, the const char *key argument is a bit of a misnomer; the docs call it uuid, and we DO have a fixed bound for UUID length, which is much smaller than PATH_MAX (we also have VIR_UUID_STRING_BUFLEN defined in libvirt.h). As you told above, I replaced all PATH_MAX for MAX_KEY_SIZE +int +phypStoragePoolListVolumes(virStoragePoolPtr pool, char **const volumes, + int nvolumes) +{ ... +virBufferVSprintf(&buf, "|sed '1d'|sed '1d'"); Save a process: ...|sed '1d'|sed '1d' is equivalent to: ...|sed 2d This is an odd behaviour. On my bash, (Ubuntu 10.04), sed '2d' and sed '1d'|sed '1d' removes the second line of the stream. But the on the HMC, sed '1d'|sed '1' removes the first two lines of the stream and sed '2d' removes the second line. And what I need is to remove the first two lines, so keeping sed '1d'|sed '1d'. +int +phypStoragePoolNumOfVolumes(virStoragePoolPtr pool) +{ ... +virBufferVSprintf(&buf, "|sed '1d'|sed '1d'|grep -c '^.*$'"); Here, rather than using sed '1d' twice,... + +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd,&exit_status, conn); + +if (exit_status< 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret,&char_ptr, 10,&nvolumes) == -1) +goto err; ...just subtract 2 from nvolumes here in C code. Wise! +int +phypDestroyStoragePool(virStoragePoolPtr pool) +{ ... +if (system_type == HMC) { +virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ", + managed_system, vios_id); +virBufferVSprintf(&buf, "'rmsp %s'", pool->name); +} else { +virBufferVSprintf(&buf, "'rmsp %s'", pool->name); +} Looks like you typo'd the IVM line (left the '' in, so you will fail trying to call the command "rmsp name" rather than the intended command "rmsp" with argument "name"). Another reason why refactoring your code to share just a single rmsp C string will help avoid mistakes like this. Fixed as you suggested up above. +virStoragePoolPtr +phypStoragePoolCreateXML(virConnectPtr conn, + const char *xml, + unsigned int flags ATTRIBUTE_UNUSED) +{ + +virStoragePoolDefPtr def = NULL; +virStoragePoolPtr sp = NULL; virCheckFlags(0, NULL) (won't comment on it any more for this round of review...) +virStoragePoolPtr +phypGetStoragePoolLookUpByUUID(virConnectPtr conn, + const unsigned char *uuid) +{ ... +if (STREQLEN((char *) local_uuid, (char *) uuid, VIR_UUID_BUFLEN)) { Here, it is simpler to avoid the casts, by doing: if (!memcmp(local_uuid, uuid, VIR_UUID_BUFLEN)) { It also matches existing style in the rest of libvirt ('git grep "STREQLEN.*VIR_UUID"' vs. 'git grep -i "cmp.*VIR_UUID_BUFLEN"'). Ok. +int +phypNumOfStoragePools(virConnectPtr conn) +{ +} else { +virBufferVSprintf(&buf, "lsvg"); +} +virBufferVSprintf(&buf, "grep -c '^.*$'"); Missing a '|' before the grep. Ok. +} + +phypStorageOpen(virConnectPtr conn ATTRIBUTE_UNUSED, +virConnectAuthPtr auth ATTRIBUTE_UNUSED, +int flags ATTRIBUTE_UNUSED) Add a newline between the closing } of one function and the start of another. Overall, my review was mainly focused on style and shell portability. I don't have access to a phyp setup at the moment, so I can't really test if your various command lines make sense (I'm assuming they do). Towards the end, I kept on spotting (and ignoring) the same issues again, so remember to do global searches when addressing a comment, rather than just at the place where I made the comment. But in general, this looks promising, and hopefully we can get things turned around fast enough to decide whether this is worth including in libvirt 0.8.2. All the commands are tested and studied directly on the HMC/VIOS and IVM befores inserting on C code, so they really work :) All the issues you pointed were fixed in all worldwide code (not just the storage driver) Will send another patch right away after reading all the comments and making all the properly fixes. Thanks for all the comments! -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] phyp: Adding storage management driver
Hello Folks, This is the result of a couple of months of hard work. I added the storage management driver to the Power Hypervisor driver. This is a big but simple patch, it's just a new set of functions, nothing more. I could split it into multiple commits, but the feature freeze starts in some hours and I really reed this feature to be included in the next release. This patch includes: * Storage driver: The set of pool-* and vol-* functions. * attach-disk function. * Support for IVM on the new functions. I've been looking at this code for a long time, so I apologize now for the silly mistakes that might be present. Looking forward to see the comments. Thanks! --- src/phyp/phyp_driver.c | 1638 +++- src/phyp/phyp_driver.h | 52 ++ 2 files changed, 1688 insertions(+), 2 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index cefb8be..77a74ef 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -56,6 +56,7 @@ #include "virterror_internal.h" #include "uuid.h" #include "domain_conf.h" +#include "storage_conf.h" #include "nodeinfo.h" #include "phyp_driver.h" @@ -1680,6 +1681,466 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) } +static char * +phypGetLparProfile(virConnectPtr conn, int lpar_id) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int exit_status = 0; +char *cmd = NULL; +char *ret = NULL; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +virBufferAddLit(&buf, "lssyscfg"); +if (system_type == HMC) +virBufferVSprintf(&buf, " -m %s ", managed_system); +virBufferVSprintf(&buf, + " -r prof --filter lpar_ids=%d -F name|head -n 1", + lpar_id); +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return NULL; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +char *char_ptr = strchr(ret, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +VIR_FREE(cmd); +return ret; + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return NULL; +} + +static int +phypGetVIOSNextSlotNumber(virConnectPtr conn) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; +char *profile = NULL; +int slot = 0; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +if (!(profile = phypGetLparProfile(conn, vios_id))) { +VIR_ERROR("%s", "Unable to get VIOS profile name."); +goto err; +} + +virBufferAddLit(&buf, "echo $((`lssyscfg"); +if (system_type == HMC) +virBufferVSprintf(&buf, " -m %s ", managed_system); +virBufferVSprintf(&buf, "-r prof --filter " + "profile_names=%s -F virtual_eth_adapters," + "virtual_opti_pool_id,virtual_scsi_adapters," + "virtual_serial_adapters|sed -e 's/\"//g' -e " + "'s/,/\\n/g'|sed -e 's/\\(^[0-9][0-9]\\*\\).*$/\\1/'" + "|sort|tail -n 1` +1 ))", profile); +if (virBufferError(&buf)) { +virBufferFreeAndReset(&buf); +virReportOOMError(); +return -1; +} +cmd = virBufferContentAndReset(&buf); + +ret = phypExec(session, cmd, &exit_status, conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &slot) == -1) +goto err; + +VIR_FREE(cmd); +VIR_FREE(ret); +return slot; + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return -1; +} + +static int +phypCreateServerSCSIAdapter(virConnectPtr conn) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int system_type = phyp_driver->system_type; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +char *cmd = NULL; +char *ret = NULL; +char *profile = NULL; +int slot = 0; +char *vios_name = NULL; +virBuffer buf = VIR_BUFFER_INITIALIZER; + +if (! +(vios_name = + phypGetLparNAME(session, managed_system, vios_id, conn))) { +VIR_ERROR("%s", "Unable to get VIOS name"); +goto e
Re: [libvirt] [PATCHv3] phyp: adding support for IVM
On 06/16/2010 07:04 PM, Eric Blake wrote: From: Eduardo Otubo Use virBuffer* API to contionally keep the portion of the command line specific to HMC, so that IVM can work. --- This starts from Eduardo's patch, then converts everything away from using double virAsprintf (in the HVM case) over to using virBuffer. src/phyp/phyp_driver.c | 560 +++- src/phyp/phyp_driver.h |8 + 2 files changed, 368 insertions(+), 200 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 4c6391f..cefb8be 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -66,6 +66,9 @@ virReportErrorHelper(NULL, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \ __LINE__, __VA_ARGS__) +static unsigned const int HMC = 0; +static unsigned const int IVM = 127; + /* * URI: phyp://u...@[hmc|ivm]/managed_system * */ @@ -82,7 +85,7 @@ phypOpen(virConnectPtr conn, uuid_tablePtr uuid_table = NULL; phyp_driverPtr phyp_driver = NULL; char *char_ptr; -char *managed_system; +char *managed_system = NULL; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -96,12 +99,6 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } -if (conn->uri->path == NULL) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing managed system name in phyp:// URI")); -return VIR_DRV_OPEN_ERROR; -} - if (VIR_ALLOC(phyp_driver)< 0) { virReportOOMError(); goto failure; @@ -117,36 +114,39 @@ phypOpen(virConnectPtr conn, goto failure; } -len = strlen(conn->uri->path) + 1; +if (conn->uri->path) { +len = strlen(conn->uri->path) + 1; -if (VIR_ALLOC_N(string, len)< 0) { -virReportOOMError(); -goto failure; -} +if (VIR_ALLOC_N(string, len)< 0) { +virReportOOMError(); +goto failure; +} -/* need to shift one byte in order to remove the first "/" of URI component */ -if (conn->uri->path[0] == '/') -managed_system = strdup(conn->uri->path + 1); -else -managed_system = strdup(conn->uri->path); +/* need to shift one byte in order to remove the first "/" of URI component */ +if (conn->uri->path[0] == '/') +managed_system = strdup(conn->uri->path + 1); +else +managed_system = strdup(conn->uri->path); -if (!managed_system) { -virReportOOMError(); -goto failure; -} +if (!managed_system) { +virReportOOMError(); +goto failure; +} -/* here we are handling only the first component of the path, - * so skipping the second: - * */ -char_ptr = strchr(managed_system, '/'); +/* here we are handling only the first component of the path, + * so skipping the second: + * */ +char_ptr = strchr(managed_system, '/'); -if (char_ptr) -*char_ptr = '\0'; +if (char_ptr) +*char_ptr = '\0'; -if (escape_specialcharacters(conn->uri->path, string, len) == -1) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Error parsing 'path'. Invalid characters.")); -goto failure; +if (escape_specialcharacters(conn->uri->path, string, len) == -1) { +PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Error parsing 'path'. Invalid characters.")); +goto failure; +} } if ((session = openSSHSession(conn, auth,&internal_socket)) == NULL) { @@ -160,7 +160,9 @@ phypOpen(virConnectPtr conn, uuid_table->nlpars = 0; uuid_table->lpars = NULL; -phyp_driver->managed_system = managed_system; +if (conn->uri->path) +phyp_driver->managed_system = managed_system; + phyp_driver->uuid_table = uuid_table; if ((phyp_driver->caps = phypCapsInit()) == NULL) { virReportOOMError(); @@ -169,12 +171,18 @@ phypOpen(virConnectPtr conn, conn->privateData = phyp_driver; conn->networkPrivateData = connection_data; -if (phypUUIDTable_Init(conn) == -1) + +if ((phyp_driver->system_type = phypGetSystemType(conn)) == -1) goto failure; -if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +if (phypUUIDTable_Init(conn) == -1) goto failure; +if (phyp_driver->system_type == HMC) { +if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +goto failure; +} + return VIR_DRV_OPEN_SUCCESS; failur
Re: [libvirt] [PATCH] Assing support for IVM
On 06/16/2010 04:22 PM, Eduardo Otubo wrote: Fixing all pointed in the previous email. Thanks for all the comments. --- src/phyp/phyp_driver.c | 356 +--- src/phyp/phyp_driver.h |8 + 2 files changed, 252 insertions(+), 112 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index c04a487..60e2493 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -66,6 +66,9 @@ virReportErrorHelper(NULL, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \ __LINE__, __VA_ARGS__) +static unsigned const int HMC = 0; +static unsigned const int IVM = 127; + /* * URI: phyp://u...@[hmc|ivm]/managed_system * */ @@ -82,7 +85,7 @@ phypOpen(virConnectPtr conn, uuid_tablePtr uuid_table = NULL; phyp_driverPtr phyp_driver = NULL; char *char_ptr; -char *managed_system; +char *managed_system = NULL; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -96,12 +99,6 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } -if (conn->uri->path == NULL) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing managed system name in phyp:// URI")); -return VIR_DRV_OPEN_ERROR; -} - if (VIR_ALLOC(phyp_driver)< 0) { virReportOOMError(); goto failure; @@ -117,36 +114,39 @@ phypOpen(virConnectPtr conn, goto failure; } -len = strlen(conn->uri->path) + 1; +if (conn->uri->path) { +len = strlen(conn->uri->path) + 1; -if (VIR_ALLOC_N(string, len)< 0) { -virReportOOMError(); -goto failure; -} +if (VIR_ALLOC_N(string, len)< 0) { +virReportOOMError(); +goto failure; +} -/* need to shift one byte in order to remove the first "/" of URI component */ -if (conn->uri->path[0] == '/') -managed_system = strdup(conn->uri->path + 1); -else -managed_system = strdup(conn->uri->path); +/* need to shift one byte in order to remove the first "/" of URI component */ +if (conn->uri->path[0] == '/') +managed_system = strdup(conn->uri->path + 1); +else +managed_system = strdup(conn->uri->path); -if (!managed_system) { -virReportOOMError(); -goto failure; -} +if (!managed_system) { +virReportOOMError(); +goto failure; +} -/* here we are handling only the first component of the path, - * so skipping the second: - * */ -char_ptr = strchr(managed_system, '/'); +/* here we are handling only the first component of the path, + * so skipping the second: + * */ +char_ptr = strchr(managed_system, '/'); -if (char_ptr) -*char_ptr = '\0'; +if (char_ptr) +*char_ptr = '\0'; -if (escape_specialcharacters(conn->uri->path, string, len) == -1) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Error parsing 'path'. Invalid characters.")); -goto failure; +if (escape_specialcharacters(conn->uri->path, string, len) == -1) { +PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Error parsing 'path'. Invalid characters.")); +goto failure; +} } if ((session = openSSHSession(conn, auth,&internal_socket)) == NULL) { @@ -160,7 +160,9 @@ phypOpen(virConnectPtr conn, uuid_table->nlpars = 0; uuid_table->lpars = NULL; -phyp_driver->managed_system = managed_system; +if (conn->uri->path) +phyp_driver->managed_system = managed_system; + phyp_driver->uuid_table = uuid_table; if ((phyp_driver->caps = phypCapsInit()) == NULL) { virReportOOMError(); @@ -169,12 +171,18 @@ phypOpen(virConnectPtr conn, conn->privateData = phyp_driver; conn->networkPrivateData = connection_data; -if (phypUUIDTable_Init(conn) == -1) + +if ((phyp_driver->system_type = phypGetSystemType(conn)) == -1) goto failure; -if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +if (phypUUIDTable_Init(conn) == -1) goto failure; +if (phyp_driver->system_type == HMC) { +if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +goto failure; +} + return VIR_DRV_OPEN_SUCCESS; failure: @@ -280,7 +288,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, username = virRequestUsername(auth, NULL, conn->uri->server); if (username == NULL) { -P
[libvirt] [PATCH] Assing support for IVM
Fixing all pointed in the previous email. Thanks for all the comments. --- src/phyp/phyp_driver.c | 356 +--- src/phyp/phyp_driver.h |8 + 2 files changed, 252 insertions(+), 112 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index c04a487..60e2493 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -66,6 +66,9 @@ virReportErrorHelper(NULL, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \ __LINE__, __VA_ARGS__) +static unsigned const int HMC = 0; +static unsigned const int IVM = 127; + /* * URI: phyp://u...@[hmc|ivm]/managed_system * */ @@ -82,7 +85,7 @@ phypOpen(virConnectPtr conn, uuid_tablePtr uuid_table = NULL; phyp_driverPtr phyp_driver = NULL; char *char_ptr; -char *managed_system; +char *managed_system = NULL; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -96,12 +99,6 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } -if (conn->uri->path == NULL) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing managed system name in phyp:// URI")); -return VIR_DRV_OPEN_ERROR; -} - if (VIR_ALLOC(phyp_driver) < 0) { virReportOOMError(); goto failure; @@ -117,36 +114,39 @@ phypOpen(virConnectPtr conn, goto failure; } -len = strlen(conn->uri->path) + 1; +if (conn->uri->path) { +len = strlen(conn->uri->path) + 1; -if (VIR_ALLOC_N(string, len) < 0) { -virReportOOMError(); -goto failure; -} +if (VIR_ALLOC_N(string, len) < 0) { +virReportOOMError(); +goto failure; +} -/* need to shift one byte in order to remove the first "/" of URI component */ -if (conn->uri->path[0] == '/') -managed_system = strdup(conn->uri->path + 1); -else -managed_system = strdup(conn->uri->path); +/* need to shift one byte in order to remove the first "/" of URI component */ +if (conn->uri->path[0] == '/') +managed_system = strdup(conn->uri->path + 1); +else +managed_system = strdup(conn->uri->path); -if (!managed_system) { -virReportOOMError(); -goto failure; -} +if (!managed_system) { +virReportOOMError(); +goto failure; +} -/* here we are handling only the first component of the path, - * so skipping the second: - * */ -char_ptr = strchr(managed_system, '/'); +/* here we are handling only the first component of the path, + * so skipping the second: + * */ +char_ptr = strchr(managed_system, '/'); -if (char_ptr) -*char_ptr = '\0'; +if (char_ptr) +*char_ptr = '\0'; -if (escape_specialcharacters(conn->uri->path, string, len) == -1) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Error parsing 'path'. Invalid characters.")); -goto failure; +if (escape_specialcharacters(conn->uri->path, string, len) == -1) { +PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Error parsing 'path'. Invalid characters.")); +goto failure; +} } if ((session = openSSHSession(conn, auth, &internal_socket)) == NULL) { @@ -160,7 +160,9 @@ phypOpen(virConnectPtr conn, uuid_table->nlpars = 0; uuid_table->lpars = NULL; -phyp_driver->managed_system = managed_system; +if (conn->uri->path) +phyp_driver->managed_system = managed_system; + phyp_driver->uuid_table = uuid_table; if ((phyp_driver->caps = phypCapsInit()) == NULL) { virReportOOMError(); @@ -169,12 +171,18 @@ phypOpen(virConnectPtr conn, conn->privateData = phyp_driver; conn->networkPrivateData = connection_data; -if (phypUUIDTable_Init(conn) == -1) + +if ((phyp_driver->system_type = phypGetSystemType(conn)) == -1) goto failure; -if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +if (phypUUIDTable_Init(conn) == -1) goto failure; +if (phyp_driver->system_type == HMC) { +if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +goto failure; +} + return VIR_DRV_OPEN_SUCCESS; failure: @@ -280,7 +288,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, username = virRequestUsername(auth, NULL, conn->uri->server); if (username == NULL) { -PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed")); +PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", + _("Username request failed")); goto err; } } @@ -360,7 +369,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, password = virRequestPassword(auth, username, conn->uri->serve
Re: [libvirt] [PATCH] phyp: sed cleanups
On 06/08/2010 10:17 PM, Eric Blake wrote: While I was touching the file... Thank you very much for this help :) src/phyp/phyp_driver.c | 12 ++-- 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 0f4bc20..f8d12e7 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -886,7 +886,7 @@ phypGetVIOSPartitionID(virConnectPtr conn) if (virAsprintf(&cmd, "lssyscfg -m %s -r lpar -F lpar_id,lpar_env|grep " -"vioserver|sed -s 's/,.*$//g'", managed_system)< 0) { +"vioserver|sed -s 's/,.*$//'", managed_system)< 0) { virReportOOMError(); goto err; } @@ -925,7 +925,7 @@ phypDiskType(virConnectPtr conn, char *backing_device) if (virAsprintf(&cmd, "viosvrcmd -m %s -p %d -c \"lssp -field name type " -"-fmt , -all|grep %s|sed -e 's/^.*,//g'\"", +"-fmt , -all|grep %s|sed -e 's/^.*,//'\"", managed_system, vios_id, backing_device)< 0) { virReportOOMError(); goto cleanup; @@ -983,7 +983,7 @@ phypNumDomainsGeneric(virConnectPtr conn, unsigned int type) if (virAsprintf(&cmd, "lssyscfg -r lpar -m %s -F lpar_id,state %s |grep -c " -"^[0-9]*", managed_system, state)< 0) { +"'^[0-9]*'", managed_system, state)< 0) { virReportOOMError(); goto err; } @@ -1051,7 +1051,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, if (virAsprintf (&cmd, - "lssyscfg -r lpar -m %s -F lpar_id,state %s | sed -e 's/,.*$//g'", + "lssyscfg -r lpar -m %s -F lpar_id,state %s | sed -e 's/,.*$//'", managed_system, state)< 0) { virReportOOMError(); goto err; @@ -1115,7 +1115,7 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames) if (virAsprintf (&cmd, "lssyscfg -r lpar -m %s -F name,state | grep \"Not Activated\" | " - "sed -e 's/,.*$//g'", managed_system)< 0) { + "sed -e 's/,.*$//'", managed_system)< 0) { virReportOOMError(); goto err; } @@ -1539,7 +1539,7 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) if (virAsprintf (&cmd, "chhwres -r proc -m %s --id %d -o %c --procunits %d 2>&1 |sed" - "-e 's/^.*\\([0-9]\\+.[0-9]\\+\\).*$/\\1/g'", + "-e 's/^.*\\([0-9][0-9]*.[0-9][0-9]*\\).*$/\\1/'", managed_system, dom->id, operation, amount)< 0) { virReportOOMError(); goto err; I tested all the changes here and it's all ACK for me. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Adding support for IVM
Adding support for the IBM IVM Virtualization system under Power Hypervisor. --- src/phyp/phyp_driver.c | 644 ++-- src/phyp/phyp_driver.h |8 + 2 files changed, 471 insertions(+), 181 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index f8bea42..787b93d 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -66,6 +66,9 @@ virReportErrorHelper(NULL, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \ __LINE__, __VA_ARGS__) +#define HMC 0 +#define IVM 127 + /* * URI: phyp://u...@[hmc|ivm]/managed_system * */ @@ -82,7 +85,7 @@ phypOpen(virConnectPtr conn, uuid_tablePtr uuid_table = NULL; phyp_driverPtr phyp_driver = NULL; char *char_ptr; -char *managed_system; +char *managed_system = NULL; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -96,12 +99,6 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } -if (conn->uri->path == NULL) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing managed system name in phyp:// URI")); -return VIR_DRV_OPEN_ERROR; -} - if (VIR_ALLOC(phyp_driver) < 0) { virReportOOMError(); goto failure; @@ -117,36 +114,39 @@ phypOpen(virConnectPtr conn, goto failure; } -len = strlen(conn->uri->path) + 1; +if (conn->uri->path) { +len = strlen(conn->uri->path) + 1; -if (VIR_ALLOC_N(string, len) < 0) { -virReportOOMError(); -goto failure; -} +if (VIR_ALLOC_N(string, len) < 0) { +virReportOOMError(); +goto failure; +} -/* need to shift one byte in order to remove the first "/" of URI component */ -if (conn->uri->path[0] == '/') -managed_system = strdup(conn->uri->path + 1); -else -managed_system = strdup(conn->uri->path); +/* need to shift one byte in order to remove the first "/" of URI component */ +if (conn->uri->path[0] == '/') +managed_system = strdup(conn->uri->path + 1); +else +managed_system = strdup(conn->uri->path); -if (!managed_system) { -virReportOOMError(); -goto failure; -} +if (!managed_system) { +virReportOOMError(); +goto failure; +} -/* here we are handling only the first component of the path, - * so skipping the second: - * */ -char_ptr = strchr(managed_system, '/'); +/* here we are handling only the first component of the path, + * so skipping the second: + * */ +char_ptr = strchr(managed_system, '/'); -if (char_ptr) -*char_ptr = '\0'; +if (char_ptr) +*char_ptr = '\0'; -if (escape_specialcharacters(conn->uri->path, string, len) == -1) { -PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Error parsing 'path'. Invalid characters.")); -goto failure; +if (escape_specialcharacters(conn->uri->path, string, len) == -1) { +PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Error parsing 'path'. Invalid characters.")); +goto failure; +} } if ((session = openSSHSession(conn, auth, &internal_socket)) == NULL) { @@ -160,7 +160,9 @@ phypOpen(virConnectPtr conn, uuid_table->nlpars = 0; uuid_table->lpars = NULL; -phyp_driver->managed_system = managed_system; +if (conn->uri->path) +phyp_driver->managed_system = managed_system; + phyp_driver->uuid_table = uuid_table; if ((phyp_driver->caps = phypCapsInit()) == NULL) { virReportOOMError(); @@ -169,12 +171,18 @@ phypOpen(virConnectPtr conn, conn->privateData = phyp_driver; conn->networkPrivateData = connection_data; -if (phypUUIDTable_Init(conn) == -1) + +if ((phyp_driver->system_type = phypGetSystemType(conn)) == -1) goto failure; -if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +if (phypUUIDTable_Init(conn) == -1) goto failure; +if (phyp_driver->system_type == HMC) { +if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +goto failure; +} + return VIR_DRV_OPEN_SUCCESS; failure: @@ -280,7 +288,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, username = virRequestUsername(auth, NULL, conn->uri->server); if (username == NULL) { -PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed")); +PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", + _("Username request failed")); goto err; } } @@ -360,7 +369,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, password = virRequestPassword(auth, username, conn->uri->server); if (password == NULL)
[libvirt] FISL 11 - Abstract submited
Hello all, For those who do not know, FISL[1] is the Brazilian International Forum of Free Software (the acronym is in pt_BR). It hits the 11th edition this year and it's going to happen from 21st to 24th of July in Porto Alegre. Last year, Daniel Veillard was invited to talk about Libvirt. I was excited to see his lecture but ended up he couldn't come. This year, I volunteered myself to speak about the project on the event, DV said it was a great idea because he couldn't come again and nobody from project would do as well. The thing is, I submited the abstract for early review a few weeks ago, and I still don't know if it was approved or not. But I don't want to wait the answer to start working on the slides and the content of the lecture, need to get it done as soon as possible to make a great work for us all. My idea is to talk about (not on this order): * How libvirt works / macro view / cases * Internals The audience will be very technical, but some business guys will be around. That's why I put that high level information in the list. Also, I will have a event here in IBM called "Technical Vitality Day". I should talk about Libvirt as well, almost on the same way of FISL, some high level information and then some internals. So, I am opening this topic for comments and ideas. Any kind of help will be very welcome :) Thanks, [1] - http://softwarelivre.org/fisl11 -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Strict check when listing domains
Now sending patches using format-patch and send-email, pretty interesting! This is the final version, fixing the style according to the new HACKING file. --- src/phyp/phyp_driver.c | 34 ++ 1 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 8a9c7a6..f8bea42 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1857,41 +1857,34 @@ phypUUIDTable_Init(virConnectPtr conn) { uuid_tablePtr uuid_table; phyp_driverPtr phyp_driver; -int nids = 0; +int nids_numdomains = 0; +int nids_listdomains = 0; int *ids = NULL; unsigned int i = 0; -if ((nids = phypNumDomainsGeneric(conn, 2)) < 0) +if ((nids_numdomains = phypNumDomainsGeneric(conn, 2)) < 0) goto err; -/* exit early if there are no domains */ -if (nids == 0) -return 0; - -if (VIR_ALLOC_N(ids, nids) < 0) { +if (VIR_ALLOC_N(ids, nids_numdomains) < 0) { virReportOOMError(); goto err; } -if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0) +if ((nids_listdomains = + phypListDomainsGeneric(conn, ids, nids_numdomains, 1)) < 0) goto err; /* exit early if there are no domains */ -/* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric() - *returned 0. indicates this an error condition? - *an even stricter check would be to treat - * - * phypNumDomainsGeneric() != phypListDomainsGeneric() - * - *as an error */ -if (nids == 0) { -VIR_FREE(ids); -return 0; +if (nids_numdomains == 0 && nids_listdomains == 0) +goto exit; +else if (nids_numdomains != nids_listdomains) { +VIR_ERROR0(_("Unable to determine number of domains.")); +goto err; } phyp_driver = conn->privateData; uuid_table = phyp_driver->uuid_table; -uuid_table->nlpars = nids; +uuid_table->nlpars = nids_listdomains; /* try to get the table from server */ if (phypUUIDTable_Pull(conn) == -1) { @@ -1905,7 +1898,8 @@ phypUUIDTable_Init(virConnectPtr conn) uuid_table->lpars[i]->id = ids[i]; if (virUUIDGenerate(uuid_table->lpars[i]->uuid) < 0) -VIR_WARN("Unable to generate UUID for domain %d", ids[i]); +VIR_WARN("Unable to generate UUID for domain %d", + ids[i]); } } else { virReportOOMError(); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Strict check when listing domains
Sorry for the late review... diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 4f7efdb..eb6be32 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1849,41 +1849,32 @@ phypUUIDTable_Init(virConnectPtr conn) { uuid_tablePtr uuid_table; phyp_driverPtr phyp_driver; -int nids = 0; +int nids_numdomains = 0; +int nids_listdomains = 0; int *ids = NULL; unsigned int i = 0; -if ((nids = phypNumDomainsGeneric(conn, 2))< 0) +if ((nids_numdomains = phypNumDomainsGeneric(conn, 2))< 0) +goto err; + +if ((nids_listdomains = + phypListDomainsGeneric(conn, ids, nids_listdomains, 1))< 0) I think you want to call phypListDomainsGeneric(conn, ids, nids_numdomains, 1) instead of phypListDomainsGeneric(conn, ids, nids_listdomains, 1) Also, you have to move the allocation of ids before the call to phypListDomainsGeneric. Otherwise you're calling phypListDomainsGeneric with ids = NULL resulting in a segfault. Because you currently pass nids_listdomains (which is always 0 at this point) to phypListDomainsGeneric you don't trigger the segfault. Thanks for the comments, all fixed :-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 8a9c7a6..423c95d 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1857,41 +1857,33 @@ phypUUIDTable_Init(virConnectPtr conn) { uuid_tablePtr uuid_table; phyp_driverPtr phyp_driver; -int nids = 0; +int nids_numdomains = 0; +int nids_listdomains = 0; int *ids = NULL; unsigned int i = 0; -if ((nids = phypNumDomainsGeneric(conn, 2)) < 0) +if ((nids_numdomains = phypNumDomainsGeneric(conn, 2)) < 0) goto err; -/* exit early if there are no domains */ -if (nids == 0) -return 0; - -if (VIR_ALLOC_N(ids, nids) < 0) { +if (VIR_ALLOC_N(ids, nids_numdomains) < 0) { virReportOOMError(); goto err; } -if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0) +if ((nids_listdomains = + phypListDomainsGeneric(conn, ids, nids_numdomains, 1)) < 0) goto err; /* exit early if there are no domains */ -/* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric() - *returned 0. indicates this an error condition? - *an even stricter check would be to treat - * - * phypNumDomainsGeneric() != phypListDomainsGeneric() - * - *as an error */ -if (nids == 0) { -VIR_FREE(ids); -return 0; -} +if (nids_numdomains != nids_listdomains){ +VIR_ERROR(_("Unable to determine number of domains.")); +goto err; +}else if (nids_numdomains == 0 && nids_listdomains == 0) +goto exit; phyp_driver = conn->privateData; uuid_table = phyp_driver->uuid_table; -uuid_table->nlpars = nids; +uuid_table->nlpars = nids_listdomains; /* try to get the table from server */ if (phypUUIDTable_Pull(conn) == -1) { -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] vol-list and other vol-* functions
Hello all, When implementing the vol-list function I came up with the concept of 'path' which I am not sure if I understood. Does 'path' in this case represents where it is mounted on the guest system? On IBM Power Hypervisor, there's some logical volumes which I can get the path and there's some I can't, hence, I can't get LookUpByPath() function implemented correctly. Any ideas? Thanks, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] phyp: first part of storage management driver
On 05/24/2010 09:27 PM, Stefan Berger wrote: Eduardo Otubo wrote on 05/18/2010 05:01:40 PM: > Please respond to otubo > > On 05/14/2010 05:27 PM, Stefan Berger wrote: > > > + > > > +virStoragePoolPtr > > > +phypSPLookupByName(virConnectPtr conn, const char *sp_name) > > > +{ > > > + virStoragePoolPtr sp = NULL; > > > + int sp_id = 0; > > > + unsigned char sp_uuid[VIR_UUID_BUFLEN]; > > > + > > > + sp_id = phypGetStoragePoolID(sp_name, conn); > > > + if (sp_id == -1) > > > + return NULL; > > > + > > > + if (phypGetStoragePoolUUID(sp_uuid, sp_name, conn) == -1) > > > + return NULL; > > > + > > > + sp = virGetStoragePool(conn, sp_name, sp_uuid); > > > + > > > + if (sp) > > > + return sp; > > > + else > > > + return NULL; > > > > Doesn't seem necessary to do if - then here. > > > > Just a 'return sp;' should do the trick. > > Above the old. I am sorry, I mistakenly attached an outdated patch. I am working on a final version of this patch with all the storage functions implemented. And all this minor issues will be fixed. BTW, the *char_ptr you asked to remove (and replace it with NULL) broke the driver. The virStrToLong_i checks for error on src/util/util.c:1988 and if **end_ptr is NULL, then err will not be NULL, making the function return -1. So I put the *char_ptr back. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: fix HTML errors in nwfilter docs
On 05/25/2010 08:22 PM, Eric Blake wrote: A build on Ubuntu reported: || Generating formatnwfilter.html.tmp /dados/develop/libvirt/docs/formatnwfilter.html.in|390| HTML parser error : Unexpected end tag : p || || ^ /dados/develop/libvirt/docs/formatnwfilter.html.in|705| HTML parser error : Unexpected end tag : code ||End of range of valid source ports || ^ /dados/develop/libvirt/docs/formatnwfilter.html.in|710| HTML parser error : Unexpected end tag : code ||Start of range of valid destination ports || ^ * docs/formatnwfilter.html.in: Fix invalid HTML constructs. Reported by Eduardo Otubo. Tested on my Ubuntu 10.04. ACK. --- Don't know why a build on Fedora didn't catch these, so I won't push until I get an ack that this fixes things on Ubuntu. docs/formatnwfilter.html.in | 11 ++- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/formatnwfilter.html.in b/docs/formatnwfilter.html.in index f03e9ce..586a4fb 100644 --- a/docs/formatnwfilter.html.in +++ b/docs/formatnwfilter.html.in @@ -384,10 +384,11 @@ Valid Strings forprotocolid are: arp, rarp, ipv4, ipv6 - - Example:<mac match='no' srcmacaddr='$MAC'/> - + +[...] +<mac match='no' srcmacaddr='$MAC'/> + ARP/RARP @@ -702,12 +703,12 @@ srcportend UINT16 -End of range of valid source ports +End of range of valid source ports dstportstart UINT16 -Start of range of valid destination ports +Start of range of valid destination ports dstportend -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] virDrvStorageVolLookupByKey and virDrvStorageVolLookupByPath should use virStoragePoolPtr as parameter
Hello, These two functions, virDrvStorageVolLookupByKey and virDrvStorageVolLookupByPath should use virStoragePoolPtr as parameter instead of virConnectPtr for some few reasons: 1) Should follow the standard virStorage*Ptr parameters like the rest of storage related functions. 2) Functions now are able to access pool structure. This is particularly important for the optimization of the PowerHypervisor phypVolumeLookupByKey function. Thanks, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- diff --git a/src/driver.h b/src/driver.h index 0975b59..bb05306 100644 --- a/src/driver.h +++ b/src/driver.h @@ -798,10 +798,10 @@ typedef virStorageVolPtr (*virDrvStorageVolLookupByName) (virStoragePoolPtr pool, const char *name); typedef virStorageVolPtr -(*virDrvStorageVolLookupByKey) (virConnectPtr pool, +(*virDrvStorageVolLookupByKey) (virStoragePoolPtr pool, const char *key); typedef virStorageVolPtr -(*virDrvStorageVolLookupByPath) (virConnectPtr pool, +(*virDrvStorageVolLookupByPath) (virStoragePoolPtr pool, const char *path); diff --git a/src/libvirt.c b/src/libvirt.c index 9d42c76..c43ce9c 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -8418,11 +8418,12 @@ error: * Returns a storage volume, or NULL if not found / error */ virStorageVolPtr -virStorageVolLookupByKey(virConnectPtr conn, +virStorageVolLookupByKey(virStoragePoolPtr pool, const char *key) { -DEBUG("conn=%p, key=%s", conn, key); +DEBUG("pool=%p, key=%s", pool, key); +virConnectPtr conn = pool->conn; virResetLastError(); if (!VIR_IS_CONNECT(conn)) { @@ -8437,7 +8438,7 @@ virStorageVolLookupByKey(virConnectPtr conn, if (conn->storageDriver && conn->storageDriver->volLookupByKey) { virStorageVolPtr ret; -ret = conn->storageDriver->volLookupByKey (conn, key); +ret = conn->storageDriver->volLookupByKey (pool, key); if (!ret) goto error; return ret; @@ -8461,11 +8462,12 @@ error: * Returns a storage volume, or NULL if not found / error */ virStorageVolPtr -virStorageVolLookupByPath(virConnectPtr conn, +virStorageVolLookupByPath(virStoragePoolPtr pool, const char *path) { -DEBUG("conn=%p, path=%s", conn, path); +DEBUG("pool=%p, path=%s", pool, path); +virConnectPtr conn = pool->conn; virResetLastError(); if (!VIR_IS_CONNECT(conn)) { @@ -8480,7 +8482,7 @@ virStorageVolLookupByPath(virConnectPtr conn, if (conn->storageDriver && conn->storageDriver->volLookupByPath) { virStorageVolPtr ret; -ret = conn->storageDriver->volLookupByPath (conn, path); +ret = conn->storageDriver->volLookupByPath (pool, path); if (!ret) goto error; return ret; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 80977a3..12380f4 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5559,9 +5559,10 @@ done: } static virStorageVolPtr -remoteStorageVolLookupByKey (virConnectPtr conn, +remoteStorageVolLookupByKey (virStoragePoolPtr pool, const char *key) { +virConnectPtr conn = pool->conn; virStorageVolPtr vol = NULL; remote_storage_vol_lookup_by_key_args args; remote_storage_vol_lookup_by_key_ret ret; @@ -5586,9 +5587,10 @@ done: } static virStorageVolPtr -remoteStorageVolLookupByPath (virConnectPtr conn, +remoteStorageVolLookupByPath (virStoragePoolPtr pool, const char *path) { +virConnectPtr conn = pool->conn; virStorageVolPtr vol = NULL; remote_storage_vol_lookup_by_path_args args; remote_storage_vol_lookup_by_path_ret ret; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index b148e39..25fe1d1 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1168,8 +1168,9 @@ cleanup: static virStorageVolPtr -storageVolumeLookupByKey(virConnectPtr conn, +storageVolumeLookupByKey(virStoragePoolPtr pool, const char *key) { +virConnectPtr conn = pool->conn; virStorageDriverStatePtr driver = conn->storagePrivateData; unsigned int i; virStorageVolPtr ret = NULL; @@ -1199,8 +1200,9 @@ storageVolumeLookupByKey(virConnectPtr conn, } static virStorageVolPtr -storageVolumeLookupByPath(virConnectPtr conn, +storageVolumeLookupByPath(virStoragePoolPtr pool, const char *path) { +virConnectPtr conn = pool->conn; virStorageDriverStatePtr driver = conn
Re: [libvirt] [PATCH] phyp: first part of storage management driver
md = NULL; +char *ret = NULL; +char *storage_pools = NULL; +char *char_ptr2 = NULL; + +if (virAsprintf +(&cmd, + "viosvrcmd -m %s --id %d -c 'lsvg'", + managed_system, vios_id) < 0) { +virReportOOMError(); +goto err; +} + +ret = phypExec(session, cmd, &exit_status, conn); + +/* I need to parse the textual return in order to get the storage pools */ +if (exit_status < 0 || ret == NULL) +goto err; +else { +storage_pools = ret; + +while (got < npools) { +char_ptr2 = strchr(storage_pools, '\n'); + +if (char_ptr2) { +*char_ptr2 = '\0'; +if ((pools[got++] = strdup(storage_pools)) == NULL) { +virReportOOMError(); +goto err; +} +char_ptr2++; +storage_pools = char_ptr2; +} else +break; +} +} + +VIR_FREE(cmd); +VIR_FREE(ret); +return got; + + err: +for (i = 0; i < got; i++) +VIR_FREE(pools[i]); +VIR_FREE(cmd); + VIR_FREE(ret); +return -1; +} + +virDrvOpenStatus +phypStorageOpen(virConnectPtr conn ATTRIBUTE_UNUSED, +virConnectAuthPtr auth ATTRIBUTE_UNUSED, +int flags ATTRIBUTE_UNUSED) +{ +return VIR_DRV_OPEN_SUCCESS; +} + +int +phypStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ +return 0; +} + int phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) { @@ -2209,6 +2682,10 @@ waitsocket(int socket_fd, LIBSSH2_SESSION * session) int phypRegister(void) { -virRegisterDriver(&phypDriver); +if (virRegisterDriver(&phypDriver) < 0) +return -1; +if (virRegisterStorageDriver(&phypStorageDriver) < 0) +return -1; + return 0; } diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h index f680994..8a7e8dc 100644 --- a/src/phyp/phyp_driver.h +++ b/src/phyp/phyp_driver.h @@ -69,6 +69,43 @@ struct _phyp_driver { char *managed_system; }; + +/* + * Common storage functions + * */ + +char * phypGetStoragePoolDevice(virConnectPtr conn, char *name); + +unsigned long int phypGetStoragePoolSize(virConnectPtr conn, char *name); + +char * phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags); + +virStoragePoolPtr phypGetStorageLookUpByUUID(virConnectPtr conn, const unsigned char *uuid); + +char * phypGetStoragePoolName(virConnectPtr conn, unsigned int id); + +int phypGetStoragePoolID(virConnectPtr conn, const char *name); + +int phypGetStoragePoolUUID(virConnectPtr conn, unsigned char *uuid, + const char *name); + +virStoragePoolPtr phypSPLookupByName(virConnectPtr conn, const char *name); + +int phypNumOfStoragePools(virConnectPtr conn); + +int phypListStoragePools(virConnectPtr conn, char **const pools, + int npools); + +virDrvOpenStatus phypStorageOpen(virConnectPtr conn ATTRIBUTE_UNUSED, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED); + +int phypStorageClose(virConnectPtr conn); + +/* + * Common driver functions + * */ + int phypCheckSPFreeSapce(virConnectPtr conn, int required_size, char *sp); int phypGetVIOSPartitionID(virConnectPtr conn); -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] phyp: first part of storage management driver
Hello all, This is the first patch about storage management driver on IBM Power Hypervisor. I reviewd a couple of times but perhaps I might be missing something. Any comments are welcome. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index cec99b1..7bd203f 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1665,6 +1665,262 @@ virDriver phypDriver = { NULL, /* domainSnapshotDelete */ }; +virStorageDriver phypStorageDriver = { +.name = "PHYP", +.open = phypStorageOpen, +.close = phypStorageClose, + +.numOfPools = phypNumOfStoragePools, +.listPools = phypListStoragePools, +.numOfDefinedPools = NULL, +.listDefinedPools = NULL, +.findPoolSources = NULL, +.poolLookupByName = phypSPLookupByName, +.poolLookupByUUID = NULL, +.poolLookupByVolume = NULL, +.poolCreateXML = NULL, +.poolDefineXML = NULL, +.poolBuild = NULL, +.poolUndefine = NULL, +.poolCreate = NULL, +.poolDestroy = NULL, +.poolDelete = NULL, +.poolRefresh = NULL, +.poolGetInfo = NULL, +.poolGetXMLDesc = NULL, +.poolGetAutostart = NULL, +.poolSetAutostart = NULL, +.poolNumOfVolumes = NULL, +.poolListVolumes = NULL, + +.volLookupByName = NULL, +.volLookupByKey = NULL, +.volLookupByPath = NULL, +.volCreateXML = NULL, +.volCreateXMLFrom = NULL, +.volDelete = NULL, +.volGetInfo = NULL, +.volGetXMLDesc = NULL, +.volGetPath = NULL, +.poolIsActive = NULL, +.poolIsPersistent = NULL +}; + +int +phypGetStoragePoolUUID(unsigned char *sp_uuid, const char *sp_name, + virConnectPtr conn) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +char *cmd = NULL; +char *ret = NULL; + +if (virAsprintf(&cmd, +"viosvrcmd -m %s --id %d -c 'lsdev -dev %s -attr " +"vgserial_id'|sed '1d'|sed '1d'", +managed_system, vios_id, sp_name, sp_name) < 0) { +virReportOOMError(); +goto err; +} + +ret = phypExec(session, cmd, &exit_status, conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (memmove(sp_uuid, ret, VIR_UUID_BUFLEN) == NULL) +goto err; + +VIR_FREE(cmd); +VIR_FREE(ret); +return 0; + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return -1; +} + +int +phypGetStoragePoolID(const char *sp_name, virConnectPtr conn) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +char *managed_system = phyp_driver->managed_system; +int vios_id = phyp_driver->vios_id; +int exit_status = 0; +int sp_id = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; + +if (virAsprintf(&cmd, +"viosvrcmd -m %s --id %d -c 'lssp -field Pool'" +"|sed '1d'|grep -n %s|sed -e 's/:.*$//g'", +managed_system, vios_id, sp_name) < 0) { +virReportOOMError(); +goto err; +} + +ret = phypExec(session, cmd, &exit_status, conn); + +if (exit_status < 0 || ret == NULL) +goto err; + +if (virStrToLong_i(ret, &char_ptr, 10, &sp_id) == -1) +goto err; + +VIR_FREE(cmd); +VIR_FREE(ret); +return sp_id; + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return -1; +} + +virStoragePoolPtr +phypSPLookupByName(virConnectPtr conn, const char *sp_name) +{ +virStoragePoolPtr sp = NULL; +int sp_id = 0; +unsigned char sp_uuid[VIR_UUID_BUFLEN]; + +sp_id = phypGetStoragePoolID(sp_name, conn); +if (sp_id == -1) +return NULL; + +if (phypGetStoragePoolUUID(sp_uuid, sp_name, conn) == -1) +return NULL; + +sp = virGetStoragePool(conn, sp_name, sp_uuid); + +if (sp) +return sp; +else +return NULL; +} + +int +phypNumOfStoragePools(virConnectPtr conn) +{ +ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; +LIBSSH2_SESSION *session = connection_data->session; +int exit_status = 0; +int nsp = 0; +char *char_ptr; +char *cmd = NULL; +char *ret = NULL; +char *managed_system = phyp_driver->managed_system; +int vios_id = phyp_driver->vios_id; + +if (virAsprintf(&
Re: [libvirt] [PATCH] Strict check when listing domains
I am really sorry. I sent an older version of the patch, here is the correct one. Eric Blake wrote: On 03/24/2010 11:19 AM, Eduardo Otubo wrote: /* exit early if there are no domains */ -if (nids == 0) +if (nids_numdomains == 0 || nids_listdomains == 0 +|| nids_numdomains != nids_listdomains) return 0; Should we be reporting an error here... -if (VIR_ALLOC_N(ids, nids) < 0) { +if (VIR_ALLOC_N(ids, nids_listdomains) < 0) { virReportOOMError(); goto err; } -if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0) -goto err; - -/* exit early if there are no domains */ -/* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric() - *returned 0. indicates this an error condition? - *an even stricter check would be to treat - * - * phypNumDomainsGeneric() != phypListDomainsGeneric() - * - *as an error */ ...given this comment? You treated it as an early exit of 0, even if both values were non-zero. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/.gnulib b/.gnulib index 4f01268..10d66ae 16 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit 4f01268d0c584c20704e42527f4fa125e7525aae +Subproject commit 10d66aedfdd610f731c8c54152b9dfca3efbee12 diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 4f7efdb..eb6be32 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1849,41 +1849,32 @@ phypUUIDTable_Init(virConnectPtr conn) { uuid_tablePtr uuid_table; phyp_driverPtr phyp_driver; -int nids = 0; +int nids_numdomains = 0; +int nids_listdomains = 0; int *ids = NULL; unsigned int i = 0; -if ((nids = phypNumDomainsGeneric(conn, 2)) < 0) +if ((nids_numdomains = phypNumDomainsGeneric(conn, 2)) < 0) +goto err; + +if ((nids_listdomains = + phypListDomainsGeneric(conn, ids, nids_listdomains, 1)) < 0) goto err; /* exit early if there are no domains */ -if (nids == 0) +if (nids_numdomains != nids_listdomains) +goto err; +else if (nids_numdomains == 0 && nids_listdomains == 0) return 0; -if (VIR_ALLOC_N(ids, nids) < 0) { +if (VIR_ALLOC_N(ids, nids_listdomains) < 0) { virReportOOMError(); goto err; } -if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0) -goto err; - -/* exit early if there are no domains */ -/* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric() - *returned 0. indicates this an error condition? - *an even stricter check would be to treat - * - * phypNumDomainsGeneric() != phypListDomainsGeneric() - * - *as an error */ -if (nids == 0) { -VIR_FREE(ids); -return 0; -} - phyp_driver = conn->privateData; uuid_table = phyp_driver->uuid_table; -uuid_table->nlpars = nids; +uuid_table->nlpars = nids_listdomains; /* try to get the table from server */ if (phypUUIDTable_Pull(conn) == -1) { -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Strict check when listing domains
-- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index e4d67dc..f9a36a1 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1846,41 +1846,31 @@ phypUUIDTable_Init(virConnectPtr conn) { uuid_tablePtr uuid_table; phyp_driverPtr phyp_driver; -int nids = 0; +int nids_numdomains = 0; +int nids_listdomains = 0; int *ids = NULL; unsigned int i = 0; -if ((nids = phypNumDomainsGeneric(conn, 2)) < 0) +if ((nids_numdomains = phypNumDomainsGeneric(conn, 2)) < 0) +goto err; + +if ((nids_listdomains = + phypListDomainsGeneric(conn, ids, nids_listdomains, 1)) < 0) goto err; /* exit early if there are no domains */ -if (nids == 0) +if (nids_numdomains == 0 || nids_listdomains == 0 +|| nids_numdomains != nids_listdomains) return 0; -if (VIR_ALLOC_N(ids, nids) < 0) { +if (VIR_ALLOC_N(ids, nids_listdomains) < 0) { virReportOOMError(); goto err; } -if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0) -goto err; - -/* exit early if there are no domains */ -/* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric() - *returned 0. indicates this an error condition? - *an even stricter check would be to treat - * - * phypNumDomainsGeneric() != phypListDomainsGeneric() - * - *as an error */ -if (nids == 0) { -VIR_FREE(ids); -return 0; -} - phyp_driver = conn->privateData; uuid_table = phyp_driver->uuid_table; -uuid_table->nlpars = nids; +uuid_table->nlpars = nids_listdomains; /* try to get the table from server */ if (phypUUIDTable_Pull(conn) == -1) { -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] phyp: too much timeout when polling socket
Hello all, Since I moved to libssh2 I had noticed a weird behaviour, virsh was taking too much time to complete the operations when using phyp driver. Just found the problem, 10 seconds of timeout passed to select(). Changed to zero, since I'm just polling the socket. Actually this patch is more important than it seems, now I can write a script (using virsh) to test all the phyp features. Thanks! []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index e9f0fec..19b46b7 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -2171,7 +2171,7 @@ waitsocket(int socket_fd, LIBSSH2_SESSION * session) fd_set *readfd = NULL; int dir; -timeout.tv_sec = 10; +timeout.tv_sec = 0; timeout.tv_usec = 0; FD_ZERO(&fd); -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] phyp: ssh authentication with pub keys fixed
Eduardo Otubo wrote: Matthias Bolte wrote: 2009/11/9 Eduardo Otubo : Matthias Bolte wrote: diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..f96d2d6 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c [...] @@ -282,10 +297,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, /* Trying authentication by pubkey */ while ((rc = libssh2_userauth_publickey_fromfile(session, username, You assign conn->uri->user to username and use it without checking for NULL. You should either check conn->uri->user for NULL in phypOpen(), as you do it for conn->uri->server and conn->uri->path, and return VIR_DRV_OPEN_ERROR if its NULL or request a username via the auth callback if conn->uri->user is NULL. Ok. -"/home/user/" -".ssh/id_rsa.pub", -"/home/user/" -".ssh/id_rsa", +pubkey, +pvtkey, password)) == The password (actually the passphrase) is NULL at this point. Is this really working? Talking with libssh2 guys, this feature is not exactly working well, they said that it is possible to pass a random passphrase (or even NULL) that it will authenticate using pub and pvt keys. So, I assumed this as a hardcoded NULL just until they fix this function. Hm, okay. May be you should add a comment about this. LIBSSH2_ERROR_EAGAIN) ; if (rc) { So you fallback to username/password authentication if keyfile authentication failed (rc != 0). According to the libssh2_userauth_publickey_fromfile manpage it may return this error codes: LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed. LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket. LIBSSH2_ERROR_SOCKET_TIMEOUT LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED - The username/public key combination was invalid. LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED - The username/public key combination was invalid, or the signature for the supplied public key was invalid. Appearently, going further the man pages and tracing all the function return points, I figured out that this function may also return LIBSSH2_ERROR_SOCKET_NONE or LIBSSH2_ERROR_NONE for many reasons. As far as I understand, LIBSSH2_ERROR_NONE is for a succesful pubkey authentication, and LIBSSH2_ERROR_SOCKET_NONE is for a non succesful. Adjusted all values for this if construction. IMHO its not useful to fallback to username/password authentication for the first three possible errors, only if a keyfile related error occurs like the last two. In this case I explicit check for errors (LIBSSH2_ERROR_ALLOC, LIBSSH2_ERROR_SOCKET_SEND and LIBSSH2_ERROR_SOCKET_TIMEOUT) before fallback. I wonder which error code will be returned if one or both keyfiles don't exist. Maybe you should check if both keyfiles exist before calling libssh2_userauth_publickey_fromfile() and fallback to username/password authentication if one or both are missing. Ok. I am stating files now. @@ -341,15 +354,22 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, goto disconnect; } else goto exit; +} else { +goto exit; } disconnect: libssh2_session_disconnect(session, "Disconnecting..."); libssh2_session_free(session); err: +VIR_FREE(userhome); +VIR_FREE(pubkey); +VIR_FREE(pvtkey); VIR_FREE(password); return NULL; exit: +VIR_FREE(userhome); VIR_FREE(pubkey) is missing here, it's there in the first version of this patch. Ok. Thanks again :) []'s diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..94581b2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c [...] @@ -280,15 +302,19 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, } /* Trying authentication by pubkey */ +if (stat(pvtkey, &pvt_stat) || stat(pubkey, &pub_stat)) You could have used access(pvtkey, R_OK) instead, but stat() is okay. Don't you want to try username/password authentication in case of missing keyfiles? Instead you goto err. +goto err; + while ((rc = libssh2_userauth_publickey_fromfile(session, username, -"/home/user/" -".ssh/id_rsa.pub", -"/home/user/" -".ssh/id_rsa", -password)) == +pubkey, +
Re: [libvirt] [PATCH] phyp: ssh authentication with pub keys fixed
Matthias Bolte wrote: 2009/11/9 Eduardo Otubo : Matthias Bolte wrote: diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..f96d2d6 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c [...] @@ -282,10 +297,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, /* Trying authentication by pubkey */ while ((rc = libssh2_userauth_publickey_fromfile(session, username, You assign conn->uri->user to username and use it without checking for NULL. You should either check conn->uri->user for NULL in phypOpen(), as you do it for conn->uri->server and conn->uri->path, and return VIR_DRV_OPEN_ERROR if its NULL or request a username via the auth callback if conn->uri->user is NULL. Ok. -"/home/user/" -".ssh/id_rsa.pub", -"/home/user/" -".ssh/id_rsa", +pubkey, +pvtkey, password)) == The password (actually the passphrase) is NULL at this point. Is this really working? Talking with libssh2 guys, this feature is not exactly working well, they said that it is possible to pass a random passphrase (or even NULL) that it will authenticate using pub and pvt keys. So, I assumed this as a hardcoded NULL just until they fix this function. Hm, okay. May be you should add a comment about this. LIBSSH2_ERROR_EAGAIN) ; if (rc) { So you fallback to username/password authentication if keyfile authentication failed (rc != 0). According to the libssh2_userauth_publickey_fromfile manpage it may return this error codes: LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed. LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket. LIBSSH2_ERROR_SOCKET_TIMEOUT LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED - The username/public key combination was invalid. LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED - The username/public key combination was invalid, or the signature for the supplied public key was invalid. Appearently, going further the man pages and tracing all the function return points, I figured out that this function may also return LIBSSH2_ERROR_SOCKET_NONE or LIBSSH2_ERROR_NONE for many reasons. As far as I understand, LIBSSH2_ERROR_NONE is for a succesful pubkey authentication, and LIBSSH2_ERROR_SOCKET_NONE is for a non succesful. Adjusted all values for this if construction. IMHO its not useful to fallback to username/password authentication for the first three possible errors, only if a keyfile related error occurs like the last two. In this case I explicit check for errors (LIBSSH2_ERROR_ALLOC, LIBSSH2_ERROR_SOCKET_SEND and LIBSSH2_ERROR_SOCKET_TIMEOUT) before fallback. I wonder which error code will be returned if one or both keyfiles don't exist. Maybe you should check if both keyfiles exist before calling libssh2_userauth_publickey_fromfile() and fallback to username/password authentication if one or both are missing. Ok. I am stating files now. @@ -341,15 +354,22 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, goto disconnect; } else goto exit; +} else { +goto exit; } disconnect: libssh2_session_disconnect(session, "Disconnecting..."); libssh2_session_free(session); err: +VIR_FREE(userhome); +VIR_FREE(pubkey); +VIR_FREE(pvtkey); VIR_FREE(password); return NULL; exit: +VIR_FREE(userhome); VIR_FREE(pubkey) is missing here, it's there in the first version of this patch. Ok. Thanks again :) []'s diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..94581b2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c [...] @@ -280,15 +302,19 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, } /* Trying authentication by pubkey */ +if (stat(pvtkey, &pvt_stat) || stat(pubkey, &pub_stat)) You could have used access(pvtkey, R_OK) instead, but stat() is okay. Don't you want to try username/password authentication in case of missing keyfiles? Instead you goto err. +goto err; + while ((rc = libssh2_userauth_publickey_fromfile(session, username, -"/home/user/" -".ssh/id_rsa.pub", -"/home/user/" -".ssh/id_rsa", -password)) == +pubkey, +pvtke
Re: [libvirt] [PATCH] phyp: ssh authentication with pub keys fixed
Matthias Bolte wrote: diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..f96d2d6 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c [...] @@ -282,10 +297,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, /* Trying authentication by pubkey */ while ((rc = libssh2_userauth_publickey_fromfile(session, username, You assign conn->uri->user to username and use it without checking for NULL. You should either check conn->uri->user for NULL in phypOpen(), as you do it for conn->uri->server and conn->uri->path, and return VIR_DRV_OPEN_ERROR if its NULL or request a username via the auth callback if conn->uri->user is NULL. Ok. -"/home/user/" -".ssh/id_rsa.pub", -"/home/user/" -".ssh/id_rsa", +pubkey, +pvtkey, password)) == The password (actually the passphrase) is NULL at this point. Is this really working? Talking with libssh2 guys, this feature is not exactly working well, they said that it is possible to pass a random passphrase (or even NULL) that it will authenticate using pub and pvt keys. So, I assumed this as a hardcoded NULL just until they fix this function. LIBSSH2_ERROR_EAGAIN) ; if (rc) { So you fallback to username/password authentication if keyfile authentication failed (rc != 0). According to the libssh2_userauth_publickey_fromfile manpage it may return this error codes: LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed. LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket. LIBSSH2_ERROR_SOCKET_TIMEOUT LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED - The username/public key combination was invalid. LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED - The username/public key combination was invalid, or the signature for the supplied public key was invalid. Appearently, going further the man pages and tracing all the function return points, I figured out that this function may also return LIBSSH2_ERROR_SOCKET_NONE or LIBSSH2_ERROR_NONE for many reasons. As far as I understand, LIBSSH2_ERROR_NONE is for a succesful pubkey authentication, and LIBSSH2_ERROR_SOCKET_NONE is for a non succesful. Adjusted all values for this if construction. IMHO its not useful to fallback to username/password authentication for the first three possible errors, only if a keyfile related error occurs like the last two. In this case I explicit check for errors (LIBSSH2_ERROR_ALLOC, LIBSSH2_ERROR_SOCKET_SEND and LIBSSH2_ERROR_SOCKET_TIMEOUT) before fallback. I wonder which error code will be returned if one or both keyfiles don't exist. Maybe you should check if both keyfiles exist before calling libssh2_userauth_publickey_fromfile() and fallback to username/password authentication if one or both are missing. Ok. I am stating files now. @@ -341,15 +354,22 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, goto disconnect; } else goto exit; +} else { +goto exit; } disconnect: libssh2_session_disconnect(session, "Disconnecting..."); libssh2_session_free(session); err: +VIR_FREE(userhome); +VIR_FREE(pubkey); +VIR_FREE(pvtkey); VIR_FREE(password); return NULL; exit: +VIR_FREE(userhome); VIR_FREE(pubkey) is missing here, it's there in the first version of this patch. Ok. Thanks again :) []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..94581b2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -101,6 +101,12 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } +if (conn->uri->user == NULL) { +PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR, + _("Missing username in phyp:// URI")); +return VIR_DRV_OPEN_ERROR; +} + if (VIR_ALLOC(phyp_driver) < 0) { virReportOOMError(conn); goto failure; @@ -225,10 +231,26 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, const char *password = NULL; int sock; int rc; - struct addrinfo *ai = NULL, *cur; struct addrinfo hints; int ret; +char *pubkey = NULL; +char *pvtkey = NULL; +char *userhome = virGetUserDirectory(NULL, geteuid()); +struct stat pvt_stat, pub_stat; + +if (userhome == NULL) +goto err; + +if (virAsprintf(&pubkey, "%s/.ssh/id_rsa.pub", use
Re: [libvirt] [PATCH] phyp: ssh authentication with pub keys fixed
Matthias Bolte wrote: 2009/11/6 Eduardo Otubo : +char *pubkey = NULL; +char *pvtkey = NULL; + +if (virAsprintf(&pubkey, "%s/.ssh/id_rsa.pub", getenv("HOME")) < 0) { +virReportOOMError(conn); +goto err; +} + +if (virAsprintf(&pvtkey, "%s/.ssh/id_rsa", getenv("HOME")) < 0) { +virReportOOMError(conn); +goto err; +} You should use virGetUserDirectory() instead of getenv("HOME"): char *userdir = virGetUserDirectory(NULL, geteuid()); if (userdir == NULL) goto err; Matthias Here it is. Thanks again. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..16a82e7 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -230,6 +230,19 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, struct addrinfo hints; int ret; +char *pubkey = NULL; +char *pvtkey = NULL; + +if (virAsprintf(&pubkey, "%s/.ssh/id_rsa.pub", getenv("HOME")) < 0) { +virReportOOMError(conn); +goto err; +} + +if (virAsprintf(&pvtkey, "%s/.ssh/id_rsa", getenv("HOME")) < 0) { +virReportOOMError(conn); +goto err; +} + memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; hints.ai_socktype = SOCK_STREAM; @@ -282,10 +295,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, /* Trying authentication by pubkey */ while ((rc = libssh2_userauth_publickey_fromfile(session, username, -"/home/user/" -".ssh/id_rsa.pub", -"/home/user/" -".ssh/id_rsa", +pubkey, +pvtkey, password)) == LIBSSH2_ERROR_EAGAIN) ; if (rc) { @@ -341,15 +352,21 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, goto disconnect; } else goto exit; +} else { +goto exit; } disconnect: libssh2_session_disconnect(session, "Disconnecting..."); libssh2_session_free(session); err: +VIR_FREE(pubkey); +VIR_FREE(pvtkey); VIR_FREE(password); return NULL; exit: +VIR_FREE(pubkey); +VIR_FREE(pvtkey); VIR_FREE(password); return session; } diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a92046a..f96d2d6 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -225,10 +225,25 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, const char *password = NULL; int sock; int rc; - struct addrinfo *ai = NULL, *cur; struct addrinfo hints; int ret; +char *pubkey = NULL; +char *pvtkey = NULL; +char *userhome = virGetUserDirectory(NULL, geteuid()); + +if (userhome == NULL) +goto err; + +if (virAsprintf(&pubkey, "%s/.ssh/id_rsa.pub", userhome) < 0) { +virReportOOMError(conn); +goto err; +} + +if (virAsprintf(&pvtkey, "%s/.ssh/id_rsa", userhome) < 0) { +virReportOOMError(conn); +goto err; +} memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; @@ -282,10 +297,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, /* Trying authentication by pubkey */ while ((rc = libssh2_userauth_publickey_fromfile(session, username, -"/home/user/" -".ssh/id_rsa.pub", -"/home/user/" -".ssh/id_rsa", +pubkey, +pvtkey, password)) == LIBSSH2_ERROR_EAGAIN) ; if (rc) { @@ -341,15 +354,22 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, goto disconnect; } else goto exit; +} else { +goto exit; } disconnect: libssh2_session_disconnect(session, "Disconnecting..."); libssh2_session_free(session); err: +VIR_FREE(userhome); +VIR_FREE(pubkey); +VIR_FREE(pvtkey); VIR_FREE(password); return NULL; exit: +VIR_FREE(userhome); +VIR_FREE(pvtkey); VIR_FREE(password); return session; } -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] create() and destroy() support for Power Hypervisor
New patch, more fixes. Matthias Bolte wrote: +static virDomainPtr +phypDomainCreateAndStart(virConnectPtr conn, + const char *xml, + unsigned int flags ATTRIBUTE_UNUSED) +{ + +ConnectionData *connection_data = conn->networkPrivateData; +LIBSSH2_SESSION *session = connection_data->session; +virDomainDefPtr def = NULL; +virDomainPtr dom = NULL; +phyp_driverPtr phyp_driver = conn->privateData; +uuid_tablePtr uuid_table = phyp_driver->uuid_table; +lparPtr *lpars = uuid_table->lpars; +unsigned int i = 0; +char *managed_system = phyp_driver->managed_system; + +if (!(def = virDomainDefParseString(conn, phyp_driver->caps, xml, +VIR_DOMAIN_XML_INACTIVE))) +goto err; + +/* checking if this name already exists on this system */ +if (phypGetLparID(session, managed_system, def->name, conn) == -1) { +VIR_WARN("%s", "LPAR name already exists."); +goto err; +} + +/* checking if ID or UUID already exists on this system */ +for (i = 0; i < uuid_table->nlpars; i++) { +if (lpars[i]->id == def->id || lpars[i]->uuid == def->uuid) { +VIR_WARN("%s", "LPAR ID or UUID already exists."); +goto err; +} +} def->id is always -1 here because you're parsing the domain XML with the VIR_DOMAIN_XML_INACTIVE flag set. +dom->conn = conn; +dom->name = def->name; +dom->id = def->id; +memmove(dom->uuid, def->uuid, VIR_UUID_BUFLEN); You're accessing a NULL pointer here. Just remove this 4 lines of code, because you're setting dom a line below anyway. +if ((dom = virGetDomain(conn, def->name, def->uuid)) == NULL) +goto err; def->id is -1 here. As I understand phypBuildLpar() it calls mksyscfg to actually define a new LPAR with a given ID. You use def->id for this. You're either defining all new LPARs with ID -1 or I misunderstand how this method is working. I was thinking I could just avoid handling the ID at all here, HMC does it by itself. So, skiping ID and just dealing with the LPAR name. +if (phypBuildLpar(conn, def) == -1) +goto err; + +if (phypDomainResume(dom) == -1) +goto err; + +return dom; + + err: +virDomainDefFree(def); +VIR_FREE(dom); +return NULL; +} + [...] -void -init_uuid_db(virConnectPtr conn) +int +phypUUIDTable_WriteFile(virConnectPtr conn) { -uuid_dbPtr uuid_db; +phyp_driverPtr phyp_driver = conn->privateData; +uuid_tablePtr uuid_table = phyp_driver->uuid_table; +unsigned int i = 0; +int fd = -1; +char local_file[] = "./uuid_table"; + +if ((fd = creat(local_file, 0755)) == -1) +goto err; + +for (i = 0; i < uuid_table->nlpars; i++) { +if (write +(fd, &uuid_table->lpars[i]->id, + sizeof(uuid_table->lpars[i]->id)) == -1) +VIR_ERROR("%s", "Unable to write information to local file."); + +if (write(fd, uuid_table->lpars[i]->uuid, VIR_UUID_BUFLEN) == -1) +VIR_ERROR("%s", "Unable to write information to local file."); +} You should goto err if a write fails, because a single failed write will corrupt the while table. You should instead check for write(...) != sizeof(uuid_table->lpars[i]->id) and write(...) != VIR_UUID_BUFLEN because write() may write less bytes than requested. +close(fd); +return 0; + + err: +close(fd); +return -1; +} + You fixed most issues in this version of the patch, but some memory leaks are still there. All the other things are fixed. Thanks for all the comments. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ef465ed..4563619 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,9 @@ #include #include #include +#include +#include +#include #include "internal.h" #include "util.h" @@ -51,15 +55,12 @@ #include "virterror_internal.h" #include "uuid.h" #include "domain_conf.h" +#include "nodeinfo.h" #include "phyp_driver.h" #define VIR_FROM_THIS VIR_FROM_PHYP -#define PHYP_CMD_DEBUG VIR_DEBUG("COMMAND:%s\n",cmd); - -static int escape_specialcharacters(char *src, char *dst, size_t dstlen); - /* * URI: phyp://u...@[hmc|ivm]/managed_system * */ @@ -72,8 +73,11 @@ phypOpen(virConnectPtr conn, ConnectionData *connection_data = NULL; char *string; s
Re: [libvirt] [PATCH] create() and destroy() support for Power Hypervisor
y to handle this. Change log: * Now we have CPU management! Now I assume the user will know how to operate a HMC/IVM IBM system. This saves a lot of (useless) coding time for me :) * I solved all the other issues Matthias pointed. Next steps: * Find a better way to handle the uuid_table files without the need of use local temp files. * Storage management. Any comments are always welcome. The comments made for this patch will be fixed in time for 0.7.3 version release. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ef465ed..5b5cb3c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,9 @@ #include #include #include +#include +#include +#include #include "internal.h" #include "util.h" @@ -51,15 +55,12 @@ #include "virterror_internal.h" #include "uuid.h" #include "domain_conf.h" +#include "nodeinfo.h" #include "phyp_driver.h" #define VIR_FROM_THIS VIR_FROM_PHYP -#define PHYP_CMD_DEBUG VIR_DEBUG("COMMAND:%s\n",cmd); - -static int escape_specialcharacters(char *src, char *dst, size_t dstlen); - /* * URI: phyp://u...@[hmc|ivm]/managed_system * */ @@ -72,8 +73,23 @@ phypOpen(virConnectPtr conn, ConnectionData *connection_data = NULL; char *string; size_t len = 0; -uuid_dbPtr uuid_db = NULL; int internal_socket; +uuid_tablePtr uuid_table = NULL; +phyp_driverPtr phyp_driver = NULL; +char *char_ptr; +char *managed_system = conn->uri->path; + +/* need to shift one byte in order to remove the first "/" of URI component */ +if (managed_system[0] == '/') +managed_system++; + +/* here we are handling only the first component of the path, + * so skipping the second: + * */ +char_ptr = strchr(managed_system, '/'); + +if (char_ptr) +*char_ptr = '\0'; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -95,7 +111,12 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } -if (VIR_ALLOC(uuid_db) < 0) { +if (VIR_ALLOC(phyp_driver) < 0) { +virReportOOMError(conn); +goto failure; +} + +if (VIR_ALLOC(uuid_table) < 0) { virReportOOMError(conn); goto failure; } @@ -129,17 +150,29 @@ phypOpen(virConnectPtr conn, connection_data->session = session; connection_data->auth = auth; -uuid_db->nlpars = 0; -uuid_db->lpars = NULL; +uuid_table->nlpars = 0; +uuid_table->lpars = NULL; -conn->privateData = uuid_db; +phyp_driver->managed_system = managed_system; +phyp_driver->uuid_table = uuid_table; +if ((phyp_driver->caps = phypCapsInit()) == NULL) { +virReportOOMError(conn); +goto failure; +} + +conn->privateData = phyp_driver; conn->networkPrivateData = connection_data; -init_uuid_db(conn); +if (phypUUIDTable_Init(conn) == -1) +goto failure; + +if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +goto failure; return VIR_DRV_OPEN_SUCCESS; failure: -VIR_FREE(uuid_db); +VIR_FREE(uuid_table); +VIR_FREE(uuid_table->lpars); VIR_FREE(connection_data); VIR_FREE(string); @@ -150,11 +183,14 @@ static int phypClose(virConnectPtr conn) { ConnectionData *connection_data = conn->networkPrivateData; +phyp_driverPtr phyp_driver = conn->privateData; LIBSSH2_SESSION *session = connection_data->session; libssh2_session_disconnect(session, "Disconnecting..."); libssh2_session_free(session); +virCapabilitiesFree(phyp_driver->caps); +VIR_FREE(phyp_driver); VIR_FREE(connection_data); return 0; } @@ -174,17 +210,16 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, struct addrinfo hints; int ret; -memset (&hints, '\0', sizeof (hints)); +memset(&hints, '\0', sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; -ret = getaddrinfo (hostname, "22", &hints, &ai); +ret = getaddrinfo(hostname, "22", &hints, &ai); if (ret != 0) { virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - _("Error while getting %s address info"), - hostname); + _("Error while getting %s address info"), hostname); goto err; } @@ -192,10
Re: [libvirt] [PATCH] create() and destroy() support for Power Hypervisor
Daniel Veillard wrote: On Mon, Oct 19, 2009 at 03:53:14PM -0200, Eduardo Otubo wrote: Mark McLoughlin wrote: On Tue, 2009-10-06 at 05:12 -0300, Eduardo Otubo wrote: I've been told that libvirt possibly would make a mini-release this week to push some major fixes on Fedora 12. F12 is frozen and there has been significant changes since 0.7.1; we don't have any immediate plans to push a new release to F12 Cheers, Mark. Hello friends, Any chance to get this patch comited? I haven't seen any comments besides Marks's. In time, I am also preparing another patch to handle the virtual CPUs. Hope I can post it until the end of this week. Well if you can fix all issues posted by Matthias in a new patch byt the end of the week, I guess this can make next release, Daniel Hello Daniel, THe ideia is to fix all these bugs and finish the cpu management implementation. Hopefully I'll post it until the end of the week. Thanks. -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] create() and destroy() support for Power Hypervisor
Mark McLoughlin wrote: On Tue, 2009-10-06 at 05:12 -0300, Eduardo Otubo wrote: I've been told that libvirt possibly would make a mini-release this week to push some major fixes on Fedora 12. F12 is frozen and there has been significant changes since 0.7.1; we don't have any immediate plans to push a new release to F12 Cheers, Mark. Hello friends, Any chance to get this patch comited? I haven't seen any comments besides Marks's. In time, I am also preparing another patch to handle the virtual CPUs. Hope I can post it until the end of this week. Thanks again, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] create() and destroy() support for Power Hypervisor
Hello all, This patch includes a lot of changes: * I changed all references of uuid_db to uuid_table. Bigger name, but this semantic has a better understanding. * Now we have a little control of UUID generated for each partition. It's based on a table that matches UUID with LPAR's IDs, I keep it in a file that is stored in the managed system (HMC or IVM). Even having isolated functions to manipulate this file I still need to implement a way to lock it and make the operation atomic to avoid corruptions. * The XML file used in the create() function still must be improved. I used the tag to make a work around to handle storage pools. Now I ask for some help, how do I use the tag if there is no reference to it at the virDomainDef structure? I've been told that libvirt possibly would make a mini-release this week to push some major fixes on Fedora 12. Is there a little possibility to push these new phyp features too? This would be very important for the phyp project, since this functions are not just to manage partitions but manipulate them. Any comments are always welcome. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ef465ed..b856078 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,9 @@ #include #include #include +#include +#include +#include #include "internal.h" #include "util.h" @@ -51,15 +55,12 @@ #include "virterror_internal.h" #include "uuid.h" #include "domain_conf.h" +#include "nodeinfo.h" #include "phyp_driver.h" #define VIR_FROM_THIS VIR_FROM_PHYP -#define PHYP_CMD_DEBUG VIR_DEBUG("COMMAND:%s\n",cmd); - -static int escape_specialcharacters(char *src, char *dst, size_t dstlen); - /* * URI: phyp://u...@[hmc|ivm]/managed_system * */ @@ -72,8 +73,9 @@ phypOpen(virConnectPtr conn, ConnectionData *connection_data = NULL; char *string; size_t len = 0; -uuid_dbPtr uuid_db = NULL; int internal_socket; +uuid_tablePtr uuid_table = NULL; +phyp_driverPtr phyp_driver = NULL; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -95,7 +97,12 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } -if (VIR_ALLOC(uuid_db) < 0) { +if (VIR_ALLOC(phyp_driver) < 0) { +virReportOOMError(conn); +goto failure; +} + +if (VIR_ALLOC(uuid_table) < 0) { virReportOOMError(conn); goto failure; } @@ -129,17 +136,25 @@ phypOpen(virConnectPtr conn, connection_data->session = session; connection_data->auth = auth; -uuid_db->nlpars = 0; -uuid_db->lpars = NULL; +uuid_table->nlpars = 0; +uuid_table->lpars = NULL; + +phyp_driver->uuid_table = uuid_table; +if ((phyp_driver->caps = phypCapsInit()) == NULL) +goto failure; -conn->privateData = uuid_db; +conn->privateData = phyp_driver; conn->networkPrivateData = connection_data; -init_uuid_db(conn); +if (phypUUIDTable_Init(conn) == -1) +goto failure; + +if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) +goto failure; return VIR_DRV_OPEN_SUCCESS; failure: -VIR_FREE(uuid_db); +VIR_FREE(uuid_table); VIR_FREE(connection_data); VIR_FREE(string); @@ -174,17 +189,16 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, struct addrinfo hints; int ret; -memset (&hints, '\0', sizeof (hints)); +memset(&hints, '\0', sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; -ret = getaddrinfo (hostname, "22", &hints, &ai); +ret = getaddrinfo(hostname, "22", &hints, &ai); if (ret != 0) { virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - _("Error while getting %s address info"), - hostname); + _("Error while getting %s address info"), hostname); goto err; } @@ -192,10 +206,10 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, while (cur != NULL) { sock = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol); if (sock >= 0) { -if (connect (sock, cur->ai_addr, cur->ai_addrlen) == 0) { +if (connect(sock, cur->ai_addr, cur->ai_addrlen) == 0) { goto connected; } -close (sock); +
Re: [libvirt] [PATCH] Power Hypervisor now with libssh2
Daniel Veillard wrote: On Wed, Aug 26, 2009 at 03:53:01AM -0300, Eduardo Otubo wrote: Hello friends, This is the new version of phyp driver now using libssh2. I also did some other changes: * Added some debug information. Sometimes its worth to know which command is being executed and where. So I added the PHYP_CMD_DEBUG macro. actually the macro should use the normal logging facilities, so I intend to clean this up. I Agree, this was an internal debug information only, forgot to remove this out. * All the connection startup is now "hard coded" in libssh2. For example, I need to open the socket and start the connection all by myself. Not a big deal, but in a near future I am planning to send a patch to libssh2 to encapsulate all these procedures into functions, hence, less code, probably less bugs :) Well for example the code was using gethostbyname which is deprecated not reentrant and the code was leaking the socket if the call failed I cleaned this up and switched to getaddrinfo() as other parts of libvirt code. Please make sure to run "make syntax-check" before sending a patch in the future, thank in advance ! I won't forgot to do the syntax-check next time. My bad. Anyway the modified patch is now commited. Please try the code as I modified the socket connection handling, The new socket connection handling is working fine, thanks :) -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 eot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Power Hypervisor now with libssh2
Hello friends, This is the new version of phyp driver now using libssh2. I also did some other changes: * Added some debug information. Sometimes its worth to know which command is being executed and where. So I added the PHYP_CMD_DEBUG macro. * All the connection startup is now "hard coded" in libssh2. For example, I need to open the socket and start the connection all by myself. Not a big deal, but in a near future I am planning to send a patch to libssh2 to encapsulate all these procedures into functions, hence, less code, probably less bugs :) * There is a lot of "out of scope" functions in the bottom of the file. In the next patch I may put all those together in a phyp_config.[ch] in order to get things clearer. What's up next: * The problem of handling the UUID in a centralized way still remains. I started to handle this by opening a sftp connection to the HMC system and transfer my UUID database. But there is an odd behavior that makes the driver connect OR NOT to some HMC systems. * CPU management: this feature planned to be released in this version is not ready yet due to the issue above. * Storage management. Vacations: I'll be on vacations from 26th/august to 14th/september. I'll check my emails in the meanwhile, but no so often. Anyway, any comments on this patch are always welcome :) []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com diff --git a/configure.in b/configure.in index d28c44a..4e933f8 100644 --- a/configure.in +++ b/configure.in @@ -187,8 +187,8 @@ AC_ARG_WITH([uml], [ --with-uml add UML support (on)],[],[with_uml=check]) AC_ARG_WITH([openvz], [ --with-openvz add OpenVZ support (on)],[],[with_openvz=yes]) -AC_ARG_WITH([libssh], -[ --with-libssh=[PFX] libssh location],[],[with_libssh=yes]) +AC_ARG_WITH([libssh2], +[ --with-libssh2=[PFX] libssh2 location],[],[with_libssh2=yes]) AC_ARG_WITH([phyp], [ --with-phyp=[PFX] add PHYP support (on)],[],[with_phyp=check]) AC_ARG_WITH([vbox], @@ -866,45 +866,45 @@ dnl dnl libssh checks dnl -if test "$with_libssh" != "yes" -a "$with_libssh" != "no"; then - libssh_path="$with_libssh" -elif test "$with_libssh" = "yes"; then - libssh_path="/usr/local/lib/" -elif test "$with_libssh" = "no"; then +if test "$with_libssh2" != "yes" -a "$with_libssh2" != "no"; then + libssh2_path="$with_libssh2" +elif test "$with_libssh2" = "yes"; then + libssh2_path="/usr/local/lib/" +elif test "$with_libssh2" = "no"; then with_phyp="no"; fi if test "$with_phyp" = "check"; then - AC_CHECK_LIB([ssh],[ssh_new],[ -LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" -AC_SUBST([LIBSSH_LIBS])],[ + AC_CHECK_LIB([ssh2],[libssh2_session_startup],[ +LIBSSH2_LIBS="$LIBSSH2_LIBS -lssh2 -L$libssh2_path" +AC_SUBST([LIBSSH2_LIBS])],[ with_phyp="no" - with_libssh="no"; + with_libssh2="no"; ],[]) if test "$with_phyp" != "no"; then - AC_CHECK_HEADERS([libssh/libssh.h],[ + AC_CHECK_HEADERS([libssh2.h],[ with_phyp="yes" -LIBSSH_CFLAGS="-I/usr/local/include/libssh" -AC_SUBST([LIBSSH_CFLAGS]) +LIBSSH2_CFLAGS="-I/usr/local/include" +AC_SUBST([LIBSSH2_CFLAGS]) AC_DEFINE_UNQUOTED([WITH_PHYP], 1, [whether IBM HMC / IVM driver is enabled]) ],[ with_phyp="no" - with_libssh="no"; + with_libssh2="no"; ],[]) fi elif test "$with_phyp" = "yes"; then - AC_CHECK_LIB([ssh],[ssh_new],[ -LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" -AC_SUBST([LIBSSH_LIBS])],[ -AC_MSG_ERROR([You must install the libssh to compile Phype driver.]) + AC_CHECK_LIB([ssh2],[libssh2_session_startup],[ +LIBSSH2_LIBS="$LIBSSH2_LIBS -lssh2 -L$libssh2_path" +AC_SUBST([LIBSSH2_LIBS])],[ +AC_MSG_ERROR([You must install the libssh2 to compile Phype driver.]) ]) - AC_CHECK_HEADERS([libssh/libssh.h],[ -LIBSSH_CFLAGS="-I/usr/local/include/libssh" -AC_SUBST([LIBSSH_CFLAGS])],[ -AC_MSG_ERROR([Cannot find libssh headers.Is libssh installed ?]) + AC_CHECK_HEADERS([libssh2.h],[ +LIBSSH2_CFLAGS="-I/usr/local/include" +AC_SUBST([LIBSSH2_CFLAGS])],[ +AC_MSG_ERROR([Cannot find libssh2 headers.Is libssh2 installed ?]) ],[]) AC_DEFINE_UNQUOTED([WITH_PHYP], 1, [whether IBM HMC / IVM driver is enabled]) @@ -1699,10 +1699,10 @@ AC_MSG_NOTICE([ libcur
Re: [libvirt] Power Hypervisor: Fix potential segfault and memleak in phypOpen
On Fri, 2009-08-07 at 15:35 +0200, Chris Lalancette wrote: > Matthias Bolte wrote: > > Hi, > > > > I came across this line in the phypOpen function: > > > > char string[strlen(conn->uri->path)]; > > > > Here the path part of the given URI is used without checking it for > > NULL, this can cause a segfault as strlen expects a string != NULL. > > Heh, it's worse than that; there is a check later on for !conn || !conn->uri, > so > you are potentially de-referencing a NULL pointer. > > > Beside that uuid_db and connection_data leak in case of an error. > > > > In this line > > > > conn->uri->path = string; > > > > the original path of the URI leaks. The patch adds a VIR_FREE call > > before setting the new path. > > > > The attached patch is compile-tested but I don't have a Power > > Hypervisor installation at hand to test it for real. > > I also don't have a Power Hypervisor, but it looks sane enough to me. I'll > say > ACK, but it's probably a good idea to get someone who has Power to test it > before you commit. > I tested with some Power machines I have over here and it is ACK for me. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Power Hypervisor support
On Fri, 2009-07-24 at 16:42 +0200, Daniel Veillard wrote: > On Wed, Jul 22, 2009 at 04:01:47PM -0300, Eduardo Otubo wrote: > > Hello everyone, > > > > This should be the official patch for the libvrt-0.7.0 release. Here > > I'll comment all the features already implemented and the roadmap we > > have ahead: > > > > Features supported: > > * Connects to HMC/VIOS or IVM systems. > > * Life cycle commands (resume and shutdown). > > * dumpxml > > * 'list' and 'list --all' > > > > What is being implemented: > > * better and centralized control for UUID > > * definexml > > * CPU management commands > > Okidoc, I have pushed them to git, congrats ! Thank you very much! :) > > > Any comment are always welcome. > [...] > > +static char * > > +phypExec(SSH_SESSION * session, char *cmd, int *exit_status, > > + virConnectPtr conn) > [...] > > +char *lpar_name = > > +phypExec(ssh_session, cmd, (int *) exit_status, conn); > > obviously those (int *) exit_status had to be changed to &exit_status > I cleaned this up before the commit :-) > > > I also had to clean a few things because the merge conflicted with the > ESX one from yesterday but nothing important. > > However I have a serioud beef with the choice of libssh. That had been > examined when this was started but I still think the issue should be > revisited: > >- ESX driver now depend on libcurl which depends on the concurrent > library libssh2 >- libssh seems in its infancy, right now the version in Fedora > development is 0.2, upstream is 0.3.1 radical change of naming >- the phyp driver fails to build against 0.2 version, as they changed > API signatures :-( , it compile agaisnt 0.3.1 but it's not > generally available. >- the -devel rpm doesn't even export a .pc file to easilly test > against a given version in configure >- rebuilding the src.rpm from upstream results in a shared lib being > installed in libssh3, and the header files being in libssh-devel, > when one consider there is also libssh2 needed for the build this > is getting very very confusing >- I have a very hard time promoting the use of a library which does > things like > typedef struct string_struct STRING; > typedef struct buffer_struct BUFFER; > and > typedef uint32_t u32; > typedef uint16_t u16; > steeping onto the global naming space and being garanteed to be a > pain in the long run (or completely break its published API to fix > it) > > So right now I had to disable compilation of phys in the rpm because > of those issues especially the API breakage leading to compilation > failure if the wrong libssh-devel version was installed and the > impossibility to test this easilly in the configure.in > > I somehow remember you might be okay to switch to libssh2 if really > needed, and considering the uglyness of libssh current state I guess > the option should be at least seriously considered. Daniel, As we talked in the IRC, I'll start working on the migration to libssh2. I'll post my feedbacks as soon as I have some compilable code to show :) []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Power Hypervisor support
On Thu, 2009-07-23 at 21:52 +0100, Daniel P. Berrange wrote: > On Wed, Jul 22, 2009 at 04:01:47PM -0300, Eduardo Otubo wrote: > > Hello everyone, > > > > This should be the official patch for the libvrt-0.7.0 release. Here > > I'll comment all the features already implemented and the roadmap we > > have ahead: > > > > Features supported: > > * Connects to HMC/VIOS or IVM systems. > > * Life cycle commands (resume and shutdown). > > * dumpxml > > * 'list' and 'list --all' > > > > What is being implemented: > > * better and centralized control for UUID > > * definexml > > * CPU management commands > > > > Any comment are always welcome. > > I think it is worth merging this patch now. While there's still > more changes I'd like to see in the code, it'll be easier to > address them once merged - keeping it out of tree for longer > is counterproductive. Yes, I agree with that. > > BTW, if you could provide a short introduction outlining any important > points for the Phyp driver that'd be great. Driver docs under under the > directory docs/drvX.html.in - the .html is generated from the > .html.in file. Just create a new docs/drvphyp.html.in, and list it in > the sitemap.html.in file Sure, I'll write some lines about how it works and so on. It should be for this release or in some future patch would be ok also? []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Power Hypervisor support
Hello everyone, This should be the official patch for the libvrt-0.7.0 release. Here I'll comment all the features already implemented and the roadmap we have ahead: Features supported: * Connects to HMC/VIOS or IVM systems. * Life cycle commands (resume and shutdown). * dumpxml * 'list' and 'list --all' What is being implemented: * better and centralized control for UUID * definexml * CPU management commands Any comment are always welcome. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com diff --git a/configure.in b/configure.in index 634e812..273afbd 100644 --- a/configure.in +++ b/configure.in @@ -187,6 +187,10 @@ AC_ARG_WITH([uml], [ --with-uml add UML support (on)],[],[with_uml=yes]) AC_ARG_WITH([openvz], [ --with-openvz add OpenVZ support (on)],[],[with_openvz=yes]) +AC_ARG_WITH([libssh], +[ --with-libssh=[PFX] libssh location],[],[with_libssh=yes]) +AC_ARG_WITH([phyp], +[ --with-phyp=[PFX] add PHYP support (on)],[with_phyp=yes],[with_phyp=check]) AC_ARG_WITH([vbox], [ --with-vbox add VirtualBox support (on)],[],[with_vbox=yes]) AC_ARG_WITH([lxc], @@ -769,7 +773,50 @@ AM_CONDITIONAL([HAVE_NUMACTL], [test "$with_numactl" != "no"]) AC_SUBST([NUMACTL_CFLAGS]) AC_SUBST([NUMACTL_LIBS]) - +if test "$with_libssh" != "yes" -a "$with_libssh" != "no"; then + libssh_path="$with_libssh" +elif test "$with_libssh" = "yes"; then + libssh_path="/usr/local/lib/" +elif test "$with_libssh" = "no"; then + with_phyp="no"; +fi + +if test "$with_phyp" = "check"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +with_phyp="no" + with_libssh="no"; +],[]) + + if test "$with_phyp" != "no"; then + AC_CHECK_HEADERS([libssh/libssh.h],[ + with_phyp="yes" +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +],[ +with_phyp="no" + with_libssh="no"; +],[]) + fi +elif test "$with_phyp" = "yes"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +AC_MSG_ERROR([You must install the libssh to compile Phype driver.]) +]) + + AC_CHECK_HEADERS([libssh/libssh.h],[ +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS])],[ +AC_MSG_ERROR([Cannot find libssh headers.Is libssh installed ?]) +],[]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +fi +AM_CONDITIONAL([WITH_PHYP],[test "$with_phyp" = "yes"]) dnl libcap-ng AC_ARG_WITH([capng], @@ -810,8 +857,6 @@ AM_CONDITIONAL([HAVE_CAPNG], [test "$with_capng" != "no"]) AC_SUBST([CAPNG_CFLAGS]) AC_SUBST([CAPNG_LIBS]) - - dnl virsh libraries AC_CHECK_HEADERS([readline/readline.h]) @@ -1491,6 +1536,7 @@ AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([VBox: $with_vbox]) AC_MSG_NOTICE([ LXC: $with_lxc]) +AC_MSG_NOTICE([PHYP: $with_phyp]) AC_MSG_NOTICE([ ONE: $with_one]) AC_MSG_NOTICE([Test: $with_test]) AC_MSG_NOTICE([ Remote: $with_remote]) @@ -1522,6 +1568,11 @@ fi AC_MSG_NOTICE([]) AC_MSG_NOTICE([Libraries]) AC_MSG_NOTICE([]) +if test "$with_libssh" != "no" ; then +AC_MSG_NOTICE([ libssh: $LIBSSH_CFLAGS $LIBSSH_LIBS]) +else +AC_MSG_NOTICE([ libssh: no]) +fi AC_MSG_NOTICE([ libxml: $LIBXML_CFLAGS $LIBXML_LIBS]) AC_MSG_NOTICE([ gnutls: $GNUTLS_CFLAGS $GNUTLS_LIBS]) if test "$with_sasl" != "no" ; then diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index f587fbf..cd2fde9 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -65,6 +65,7 @@ typedef enum { VIR_FROM_VBOX,/* Error from VirtualBox driver */ VIR_FROM_INTERFACE, /* Error when operating on an interface */ VIR_FROM_ONE, /* Error from OpenNebula driver */ +VIR_FROM_PHYP, /* Error from IBM power hypervisor */ } virErrorDomain; diff --git a/src/Makefile.am b/src/Makefile.am index 79826b1..bca9916 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ INCLUDES = \ -I../include \ -...@top_srcdir@/include \ -...@top_srcdir@/qemud \ + $(LIBSSH_CFLAGS) \ $(LIBXML_CFLAGS) \ $(XEN_CFLAGS) \ $(SELINUX_CFLAGS) \ @@ -129,6 +130,9 @@ LXC_CONTROLLER_S
Re: [libvirt] [PATCH] Power Hypervisor Support for libvirt - minimum set of features
Hello all, This is the last version of this enormous PATCH. All minor bugs are fixed, and the minimal set of features are implemented. Any comments are alwayes welcome. []'s On Tue, 2009-06-23 at 10:55 -0300, Eduardo Otubo wrote: > Hello again, > > This is the life cycle operations I've been working on these days. > Fortunately this is a smaller and more punctual diff. :) > > Any comment is always welcome. > []'s > > On Mon, 2009-06-22 at 18:57 -0300, Eduardo Otubo wrote: > > Hello all, > > > > This is the initial patch for the driver for IBM Power Hypervisors. The > > minimum set of features are now implemented: list, list --all and > > dumpxml. Here is the Changeset since last PATCH I sent: > > > > * The URI has changed to: phyp://u...@[hmc|ivm]/managed_system. If the > > system is a HMC+VIOS based, only an HMC authentication will be required. > > Commands will be sent to VIOS trough HMC command line. And if the system > > is an IVM based, then just provide the username and password for IVM. > > > > * Since the Power Hypervisor has no information about UUID's, I built a > > little database (uuid_db) to store and associate LPAR ID's with UUID > > randomly generated by the API. > > > > * The command dumpxml is implemented, but there are some informations > > missing. Fetching informations like fstab, os type, uptime, IP addr and > > so on, will only be available in a future versions of the HMC system. > > > > * The TODO list is now set to implement life cycle functions. > > > > > > Thanks in advance, > > []'s > > []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com diff --git a/configure.in b/configure.in index 29c8867..6812a39 100644 --- a/configure.in +++ b/configure.in @@ -186,6 +186,10 @@ AC_ARG_WITH([uml], [ --with-uml add UML support (on)],[],[with_uml=yes]) AC_ARG_WITH([openvz], [ --with-openvz add OpenVZ support (on)],[],[with_openvz=yes]) +AC_ARG_WITH([libssh], +[ --with-libssh=[PFX] libssh location],[],[with_libssh=yes]) +AC_ARG_WITH([phyp], +[ --with-phyp=[PFX] add PHYP support (on)],[with_phyp=yes],[with_phyp=check]) AC_ARG_WITH([vbox], [ --with-vbox add VirtualBox support (on)],[],[with_vbox=yes]) AC_ARG_WITH([lxc], @@ -768,7 +772,50 @@ AM_CONDITIONAL([HAVE_NUMACTL], [test "$with_numactl" != "no"]) AC_SUBST([NUMACTL_CFLAGS]) AC_SUBST([NUMACTL_LIBS]) - +if test "$with_libssh" != "yes" -a "$with_libssh" != "no"; then + libssh_path="$with_libssh" +elif test "$with_libssh" = "yes"; then + libssh_path="/usr/local/lib/" +elif test "$with_libssh" = "no"; then + with_phyp="no"; +fi + +if test "$with_phyp" = "check"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +with_phyp="no" + with_libssh="no"; +],[]) + + if test "$with_phyp" != "no"; then + AC_CHECK_HEADERS([libssh/libssh.h],[ + with_phyp="yes" +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +],[ +with_phyp="no" + with_libssh="no"; +],[]) + fi +elif test "$with_phyp" = "yes"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +AC_MSG_ERROR([You must install the libssh to compile Phype driver.]) +]) + + AC_CHECK_HEADERS([libssh/libssh.h],[ +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS])],[ +AC_MSG_ERROR([Cannot find libssh headers.Is libssh installed ?]) +],[]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +fi +AM_CONDITIONAL([WITH_PHYP],[test "$with_phyp" = "yes"]) dnl libcap-ng AC_ARG_WITH([capng], @@ -809,8 +856,6 @@ AM_CONDITIONAL([HAVE_CAPNG], [test "$with_capng" != "no"]) AC_SUBST([CAPNG_CFLAGS]) AC_SUBST([CAPNG_LIBS]) - - dnl virsh libraries AC_CHECK_HEADERS([readline/readline.h]) @@ -1477,6 +1522,7 @@ AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([VBox: $with_vbox]) AC_MSG_NOTICE([ LXC: $with_lxc]) +AC_MSG_NOTICE([PHYP: $with_phyp]) AC_MSG_NOTICE([ ONE: $with_one]) AC_MSG_NOTICE([Test: $with_test]) AC_
Re: [libvirt] [PATCH] Power Hypervisor Support for libvirt - minimum set of features
And all the other comments you did are now fixed. Thanks. (and sorry for the top posting) []'s On Mon, 2009-06-29 at 10:44 +0100, Daniel P. Berrange wrote: > On Mon, Jun 22, 2009 at 06:57:19PM -0300, Eduardo Otubo wrote: > > Hello all, > > > > This is the initial patch for the driver for IBM Power Hypervisors. The > > minimum set of features are now implemented: list, list --all and > > dumpxml. Here is the Changeset since last PATCH I sent: > > > > * The URI has changed to: phyp://u...@[hmc|ivm]/managed_system. If the > > system is a HMC+VIOS based, only an HMC authentication will be required. > > Commands will be sent to VIOS trough HMC command line. And if the system > > is an IVM based, then just provide the username and password for IVM. > > > > * Since the Power Hypervisor has no information about UUID's, I built a > > little database (uuid_db) to store and associate LPAR ID's with UUID > > randomly generated by the API. > > I might be missing something, but this database doesn't appear to be > persistent at all - it just lives for the duration of the virConnectPtr > object's lifetime. So if you create two connections you'd get two > different UUIDs for the same VM. > > > * The command dumpxml is implemented, but there are some informations > > missing. Fetching informations like fstab, os type, uptime, IP addr and > > so on, will only be available in a future versions of the HMC system. > > That's fine - starting simple is the way to go. > > > +/* > > + * URI: phyp://u...@[hmc|ivm]/managed_system > > + * */ > > + > > +static virDrvOpenStatus > > +phypOpen(virConnectPtr conn, > > + virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) > > +{ > > +SSH_SESSION *session; > > +ConnectionData *connection_data; > > + > > +uuid_dbPtr uuid_db = NULL; > > + > > +if (VIR_ALLOC(uuid_db) < 0) > > +virReportOOMError(conn); > > + > > +if (VIR_ALLOC(connection_data) < 0) > > +virReportOOMError(conn); > > + > > +if (!conn || !conn->uri) > > +return VIR_DRV_OPEN_DECLINED; > > + > > +if (conn->uri->scheme == NULL || conn->uri->server == NULL > > +|| conn->uri->path == NULL) > > +return VIR_DRV_OPEN_DECLINED; > > Here you need to check that the 'scheme' really is for your > driver, before continuing. If the scheme matches your driver, > then if there are any further errors such as missing server > or path, then you need to return VIR_DRV_OPEN_ERROR instead > of DECLINED. So this block should look like: > > if (conn->uri->scheme == NULL || > STRNEQ(conn->uri->scheme, "phyp") >return VIR_DRV_OPEN_DECLINED; > > > if (conn->uri->server == NULL) { > virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP, >VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", >_("Missing server name in phyp:// URI")); > return VIR_DRV_OPEN_ERROR; > } > if (conn->uri->path == NULL) { > virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP, >VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", >_("Missing path name in phyp:// URI")); > return VIR_DRV_OPEN_ERROR; > } > > > + > > +SSH_SESSION * > > +openSSHSession(virConnectPtr conn, virConnectAuthPtr auth) > > +{ > > +SSH_SESSION *session; > > +SSH_OPTIONS *opt; > > +char *user = conn->uri->user; > > +char *host = conn->uri->server; > > +int ssh_auth = 0; > > +char *banner; > > +int port = 22; > > + > > +if (conn->uri->port) > > +port = conn->uri->port; > > + > > +session = ssh_new(); > > +opt = ssh_options_new(); > > + > > +/*setting some ssh options */ > > +ssh_options_set_host(opt, host); > > +ssh_options_set_port(opt, port); > > +ssh_options_set_username(opt, user); > > +ssh_set_options(session, opt); > > + > > +/*starting ssh connection */ > > +if (ssh_connect(session)) { > > +virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP, VIR_ERR_ERROR, > > + NULL, NULL, NULL, 0, 0, "%s", > > + _("Connection failed.")); > > +ssh_disconnect(session); > > +ssh_finalize(); > > +goto err; > >
Re: [libvirt] [PATCH] Power Hypervisor Support for libvirt - minimum set of features
Hello Daniel, > I might be missing something, but this database doesn't appear to be > persistent at all - it just lives for the duration of the virConnectPtr > object's lifetime. So if you create two connections you'd get two > different UUIDs for the same VM. Yes, that's right. I thought I could make it work kinda stable before make it persistent. And here I have a little question: The way I thought I could make it persistent is just to implement the virDomainDefineXML function. This way, I would make init__uid_db() check if there is some xml file defined, if not just create a new UUID for that lpar. But, in this case, virsh/libvirtd could be run from anywhere, so the xml file would be in other machine and so on. Then I thought I could create the XML in HMC's machine, then I would have a little more control of the UUIDs. What do you think? []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Power Hypervisor Support for libvirt - minimum set of features
Hello again, This is the life cycle operations I've been working on these days. Fortunately this is a smaller and more punctual diff. :) Any comment is always welcome. []'s On Mon, 2009-06-22 at 18:57 -0300, Eduardo Otubo wrote: > Hello all, > > This is the initial patch for the driver for IBM Power Hypervisors. The > minimum set of features are now implemented: list, list --all and > dumpxml. Here is the Changeset since last PATCH I sent: > > * The URI has changed to: phyp://u...@[hmc|ivm]/managed_system. If the > system is a HMC+VIOS based, only an HMC authentication will be required. > Commands will be sent to VIOS trough HMC command line. And if the system > is an IVM based, then just provide the username and password for IVM. > > * Since the Power Hypervisor has no information about UUID's, I built a > little database (uuid_db) to store and associate LPAR ID's with UUID > randomly generated by the API. > > * The command dumpxml is implemented, but there are some informations > missing. Fetching informations like fstab, os type, uptime, IP addr and > so on, will only be available in a future versions of the HMC system. > > * The TODO list is now set to implement life cycle functions. > > > Thanks in advance, > []'s > > > -- > Libvir-list mailing list > Libvir-list@redhat.com > https://www.redhat.com/mailman/listinfo/libvir-list -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index b922ab8..0b28cff 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -585,6 +585,64 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system, } int +phypGetLparState(virConnectPtr conn, unsigned int lpar_id) +{ +ConnectionData *connection_data = conn->networkPrivateData; +SSH_SESSION *ssh_session = connection_data->session; +char *cmd; +int exit_status = 0; +char *char_ptr = NULL; +char *managed_system = conn->uri->path; + +/* need to shift one byte in order to remove the first "/" of URI component */ +if (managed_system[0] == '/') +managed_system++; + +/* here we are handling only the first component of the path, + * so skipping the second: + * */ + +char_ptr = strchr(managed_system, '/'); + +if (char_ptr) +*char_ptr = '\0'; + +if (virAsprintf(&cmd, +"lssyscfg -r lpar -m %s -F state --filter lpar_ids=%d", +managed_system, lpar_id) < 0) { +virReportOOMError(conn); +goto err; +} + +char *ret = exec(ssh_session, cmd, (int *) exit_status, conn); + +if (ret == NULL) +goto err; + +char_ptr = strchr(ret, '\n'); + +if (char_ptr) +*char_ptr = '\0'; + +if (exit_status < 0 || ret == NULL) +goto err; + +VIR_FREE(cmd); +if (STREQ(ret, "Running")) +return VIR_DOMAIN_RUNNING; +else if (STREQ(ret, "Not Activated")) +return VIR_DOMAIN_SHUTOFF; +else if (STREQ(ret, "Shutting Down")) +return VIR_DOMAIN_SHUTDOWN; +else +goto err; + + err: +VIR_FREE(cmd); +return VIR_DOMAIN_NOSTATE; +} + +int phypDiskType(virConnectPtr conn, char *backing_device) { ConnectionData *connection_data = conn->networkPrivateData; @@ -1000,6 +1058,119 @@ phypDomainDumpXML(virDomainPtr dom, int flags) return ret; } +static int +phypDomainResume(virDomainPtr dom) +{ +ConnectionData *connection_data = dom->conn->networkPrivateData; +SSH_SESSION *ssh_session = connection_data->session; +char *managed_system = dom->conn->uri->path; +int exit_status = 0; +char *char_ptr = NULL; +char *cmd; + +/* need to shift one byte in order to remove the first "/" of URI component */ +if (managed_system[0] == '/') +managed_system++; + +/* here we are handling only the first component of the path, + * so skipping the second: + * */ +char_ptr = strchr(managed_system, '/'); + +if (char_ptr) +*char_ptr = '\0'; + +if (virAsprintf +(&cmd, + "chsysstate -m %s -r lpar -o on --id %d -f %s", + managed_system, dom->id, dom->name) < 0) { +virReportOOMError(dom->conn); +goto err; +} + +char *ret = exec(ssh_session, cmd, &exit_status, dom->conn); + + err: +VIR_FREE(cmd); +VIR_FREE(ret); +return 0; + +} + +static int +phypDomainShutdown(virDomainPtr dom) +{ +ConnectionData *connection_data = dom->conn->networkPrivateData; +SSH_SESSION *ssh_session = connection_data->session; +
[libvirt] [PATCH] Power Hypervisor Support for libvirt - minimum set of features
Hello all, This is the initial patch for the driver for IBM Power Hypervisors. The minimum set of features are now implemented: list, list --all and dumpxml. Here is the Changeset since last PATCH I sent: * The URI has changed to: phyp://u...@[hmc|ivm]/managed_system. If the system is a HMC+VIOS based, only an HMC authentication will be required. Commands will be sent to VIOS trough HMC command line. And if the system is an IVM based, then just provide the username and password for IVM. * Since the Power Hypervisor has no information about UUID's, I built a little database (uuid_db) to store and associate LPAR ID's with UUID randomly generated by the API. * The command dumpxml is implemented, but there are some informations missing. Fetching informations like fstab, os type, uptime, IP addr and so on, will only be available in a future versions of the HMC system. * The TODO list is now set to implement life cycle functions. Thanks in advance, []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com diff --git a/configure.in b/configure.in index 552c761..2581fee 100644 --- a/configure.in +++ b/configure.in @@ -186,6 +186,10 @@ AC_ARG_WITH([uml], [ --with-uml add UML support (on)],[],[with_uml=yes]) AC_ARG_WITH([openvz], [ --with-openvz add OpenVZ support (on)],[],[with_openvz=yes]) +AC_ARG_WITH([libssh], +[ --with-libssh=[PFX] libssh location],[],[with_libssh=yes]) +AC_ARG_WITH([phyp], +[ --with-phyp=[PFX] add PHYP support (on)],[with_phyp=yes],[with_phyp=check]) AC_ARG_WITH([vbox], [ --with-vbox add VirtualBox support (on)],[],[with_vbox=yes]) AC_ARG_WITH([lxc], @@ -749,6 +753,51 @@ AM_CONDITIONAL([HAVE_NUMACTL], [test "$with_numactl" != "no"]) AC_SUBST([NUMACTL_CFLAGS]) AC_SUBST([NUMACTL_LIBS]) +if test "$with_libssh" != "yes" -a "$with_libssh" != "no"; then + libssh_path="$with_libssh" +elif test "$with_libssh" = "yes"; then + libssh_path="/usr/local/lib/" +elif test "$with_libssh" = "no"; then + with_phyp="no"; +fi + +if test "$with_phyp" = "check"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +with_phyp="no" + with_libssh="no"; +],[]) + + if test "$with_phyp" != "no"; then + AC_CHECK_HEADERS([libssh/libssh.h],[ + with_phyp="yes" +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +],[ +with_phyp="no" + with_libssh="no"; +],[]) + fi +elif test "$with_phyp" = "yes"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +AC_MSG_ERROR([You must install the libssh to compile Phype driver.]) +]) + + AC_CHECK_HEADERS([libssh/libssh.h],[ +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS])],[ +AC_MSG_ERROR([Cannot find libssh headers.Is libssh installed ?]) +],[]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +fi +AM_CONDITIONAL([WITH_PHYP],[test "$with_phyp" = "yes"]) + dnl virsh libraries AC_CHECK_HEADERS([readline/readline.h]) @@ -1415,6 +1464,7 @@ AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([VBox: $with_vbox]) AC_MSG_NOTICE([ LXC: $with_lxc]) +AC_MSG_NOTICE([PHYP: $with_phyp]) AC_MSG_NOTICE([ ONE: $with_one]) AC_MSG_NOTICE([Test: $with_test]) AC_MSG_NOTICE([ Remote: $with_remote]) @@ -1446,6 +1496,11 @@ fi AC_MSG_NOTICE([]) AC_MSG_NOTICE([Libraries]) AC_MSG_NOTICE([]) +if test "$with_libssh" != "no" ; then +AC_MSG_NOTICE([ libssh: $LIBSSH_CFLAGS $LIBSSH_LIBS]) +else +AC_MSG_NOTICE([ libssh: no]) +fi AC_MSG_NOTICE([ libxml: $LIBXML_CFLAGS $LIBXML_LIBS]) AC_MSG_NOTICE([ gnutls: $GNUTLS_CFLAGS $GNUTLS_LIBS]) if test "$with_sasl" != "no" ; then diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 1092896..511f0f6 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -65,6 +65,7 @@ typedef enum { VIR_FROM_VBOX,/* Error from VirtualBox driver */ VIR_FROM_INTERFACE, /* Error when operating on an interface */ VIR_FROM_ONE, /* Error from OpenNebula driver */ +VIR_FROM_PHYP, /* Error from IBM power hypervisor */ } virErrorDomain; diff --git a/src/Makefile.am b/src
[libvirt] Libtool problem
Hello all, I found this when compiling the last git commit (0a29f59e3b8e2c1fb797d2fa93831f21a3e1711e). This is the first compilation from my new Ubuntu instalation (9.04) so I cannot figure out if it is a libvirt problem or if it is any configuration problem. I configured the compilation with './configure --with-phyp=yes --with-xen=no' and the make exit is the following: ot...@lisa ~/develop/libvirt/src $ make make all-recursive make[1]: Entering directory `/home/otubo/develop/libvirt/src' Making all in gnulib/lib make[2]: Entering directory `/home/otubo/develop/libvirt/src/gnulib/lib' make all-recursive make[3]: Entering directory `/home/otubo/develop/libvirt/src/gnulib/lib' make[4]: Entering directory `/home/otubo/develop/libvirt/src/gnulib/lib' /bin/bash ../../mylibtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.. -I../../intl -g -O2 -MT c-ctype.lo -MD -MP -MF .deps/c-ctype.Tpo -c -o c-ctype.lo c-ctype.c (CC) -o c-ctype.lo c-ctype.c /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 847: X--tag=CC: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 880: libtool: ignoring unknown tag : command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 847: X--mode=compile: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1014: *** Warning: inferring the mode of operation is deprecated.: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1015: *** Future versions of Libtool will require --mode=MODE be specified.: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: Xgcc: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-DHAVE_CONFIG_H: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-I.: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-I../..: No such file or directory /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-I../../intl: No such file or directory /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-g: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-O2: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-MT: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: Xc-ctype.lo: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-MD: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-MP: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-MF: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X.deps/c-ctype.Tpo: No such file or directory /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1158: X-c: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1211: Xc-ctype.lo: command not found /home/otubo/develop/libvirt/src/gnulib/lib/../../libtool: line 1216: libtool: compile: cannot determine name of library object from `': command not found make[4]: *** [c-ctype.lo] Error 1 make[4]: Leaving directory `/home/otubo/develop/libvirt/src/gnulib/lib' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory `/home/otubo/develop/libvirt/src/gnulib/lib' make[2]: *** [all] Error 2 make[2]: Leaving directory `/home/otubo/develop/libvirt/src/gnulib/lib' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/otubo/develop/libvirt/src' make: *** [all] Error 2 It seems there is a strange error form libtool, it's not recognizing some options, or some malformed options there is being passed to libtool. I am not acquainted to libtool so, if you guys could help me understanding this issue I would be very glad. Thanks, []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
vert from NULL > terminated string, to raw byte array. This is not fixed in the phyp_driver.c that is attatched here, but will be fixed as soon as we discuss that UUID issue in the thread is just opened. > > > > static virDomainPtr > > phypDomainLookupByName(virConnectPtr conn, const char *name) > > { > > SSH_SESSION *ssh_session = conn->privateData; > > virDomainPtr dom = NULL; > > > > int lpar_id = 0; > > int exit_status = 0; > > char managed_system[strlen(conn->uri->path) - 1]; > > This is allocating a variable length array on the stack which > is something its best to avoid - prefer to allocate on the > heap instead. This also made me think a better way to handle managed_system without this stack allocation. Also fixed. > > void > > stripPath(char *striped_path, char *path) > > { > > unsigned int i = 0; > > > > for (i = 1; i <= strlen(path); i++) > > striped_path[i - 1] = path[i]; > > striped_path[i] = '\0'; > > return; > > } > > > I'm not convinced that the compiler will optimize this loop > to avoid it being O(n^2) on strlen(path). It can be simplified > by just calling strcpy, or memmove()'ing the original string > inplace. Fixed! > > > /* function to strip out the '\n' of the end of some string */ > > void > > stripNewline(char *striped_string, char *string) > > { > > unsigned int i = 0; > > > > for (i = 0; i <= strlen(string); i++) > > if (string[i] != '\n') > > striped_string[i] = string[i]; > > striped_string[strlen(string) - 1] = '\0'; > > return; > > } > > This can also be done in-place with a simple strchr() call Fixed! -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com /* * Copyright IBM Corp. 2009 * * phyp_driver.c: ssh layer to access Power Hypervisors * * Authors: * Eduardo Otubo * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include "internal.h" #include "util.h" #include "datatypes.h" #include "buf.h" #include "memory.h" #include "logging.h" #include "driver.h" #include "libvirt/libvirt.h" #include "virterror_internal.h" #include "uuid.h" #include "phyp_driver.h" #define VIR_FROM_THIS VIR_FROM_PHYP /* * TODO: I still need to implement a way to distinguish * an HMC from an IVM * */ static virDrvOpenStatus phypOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) { int ssh_auth = 0, exit_status = 0; char *banner; SSH_SESSION *session; SSH_OPTIONS *opt; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; if (conn->uri->scheme == NULL || conn->uri->server == NULL || conn->uri->path == NULL) return VIR_DRV_OPEN_DECLINED; session = ssh_new(); opt = ssh_options_new(); if (!conn->uri->port) conn->uri->port = 22; /*setting some ssh options */ ssh_options_set_host(opt, conn->uri->server); ssh_options_set_port(opt, conn->uri->port); ssh_options_set_username(opt, conn->uri->user); ssh_set_options(session, opt); /*starting ssh connection */ if (ssh_connect(session)) { virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", _("Connection failed.")); ssh_disconnect(session); ssh_finalize(); goto err; } /*trying to use pub key */ if ((ssh_auth = ssh_userauth_autopubkey(session, NULL)) == SSH_AUTH_ERROR) { VIR_WARN("%s", "Authentication with public key failed."); } if ((banner = ssh_get_issue_banner(session))) { VIR_WARN("
[libvirt] Usage of UUID
Hello all, When I started to implement phyp driver, I use to handle the UUID as a normal 'unsigned char *' with a LPAR value called "logical_serial_num" that is a string in the format "067BE8B2", an identifier. In the last comments I got from danpb and DV, they called my attention to const string at UUID handling and some funtcions that must be implemented: domainDumpXML, listDefinedDomains and numOfDefinedDomains. My question is: Once I don't have information from my hypervisor about UUID, do I have to handle UUID at "list" or "list --all" commands? Or I should keep and handle this information only when defining a domaing at libvirt? I mean, in my point of view, there is no need to generate and store a UUID while just listing LPARs in the remote server. What I should do is to generate a random UUID (and store it) just when the user decides to define it at libvirt. Am I thinking right? Thanks for the help. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Em Qua, 2009-05-06 às 09:44 +0100, Daniel P. Berrange escreveu: > On Mon, May 04, 2009 at 05:50:03PM -0300, Eduardo Otubo wrote: > > > > > > + > > > > +/* return the lpar_id given a name and a managed system name */ > > > > +static int > > > > +phypGetLparID(SSH_SESSION * ssh_session, const char *managed_system, > > > > + const char *name) > > > > +{ > > > > +int exit_status = 0; > > > > +virBuffer cmd = VIR_BUFFER_INITIALIZER; > > > > + > > > > +virBufferVSprintf(&cmd, > > > > + "lssyscfg -r lpar -m %s --filter lpar_names=%s > > > > -F lpar_id", > > > > + managed_system, name); > > > > +const char *tex_ret = > > > > +__inner_exec_command(ssh_session, > > > > virBufferContentAndReset(&cmd), > > > > + &exit_status); > > > > + > > > > +virBufferContentAndReset(&cmd); > > > > > >Huh ? you're supposed to get the resulting char *, and then free it > > >later once you're done with the data. Here youre just leaking memory > > >I'm afraid > > > > > > same thing for most of the commands in that file. > > > > Here, I just would like to free the Buffer, and this was the best way I > > find since I couldn't find any better function to manipulate this. How > > do I simply free a buffer using the internal virBuffer* API? > > The virBufferContentAndReset() method returns you the internal char * > string, and resets the virBuffer state to its inital value. You are > now owner of the char * string, and are responsible for free'ing it > when done. > > You should also check virBufferError() and report OOM error if it fails. > So, in the above example. what you'd want todo is > > static int > phypGetLparID(SSH_SESSION * ssh_session, const char *managed_system, > const char *name) > { > int exit_status = 0; > virBuffer cmd = VIR_BUFFER_INITIALIZER; > char *buf; > > virBufferVSprintf(&cmd, > "lssyscfg -r lpar -m %s --filter lpar_names=%s -F > lpar_id", > managed_system, name); > if (virBufferError(&cmd)) { > virReportOOMError(conn); > return NULL; > } > > buf = virBufferContentAndReset(&cmd); > const char *tex_ret = > __inner_exec_command(ssh_session, buf >&exit_status); > VIR_FREE(buf); >} > > > That all said, in this particular function I it is overkill to use > the virBuffer APIs, since you've only got a single printf() call > to make. virBuffer is more appropriate when you have 2 or more > printfs() or strcats() to make. If just doing a single printf, > then use virAsprintf, > > eg > > static int > phypGetLparID(SSH_SESSION * ssh_session, const char *managed_system, > const char *name) > { > int exit_status = 0; > char *buf; > > if (virAsprintf(&buf, > "lssyscfg -r lpar -m %s --filter lpar_names=%s -F > lpar_id", > managed_system, name) < 0) { > virReportOOMError(conn); > return NULL; > } > > const char *tex_ret = > __inner_exec_command(ssh_session, buf >&exit_status); > VIR_FREE(buf); >} > > > Regards, > Daniel DV and danpb, First of all, thanks for the tips. Is helping me a lot. Here is the phyp_driver.c with the memory leaks fixed with your suggestions. With those things done, do you think this code is enough and compliant to libvirt patterns to be included in the next libvirt release? The only feature we have until now is just to list the LPARs ("Logical PARtitions", the IBM virtual machines for Power). Once this code is safe and goot enough, the implementations of new commands will be much faster and easier. Here is the code: /* * Copyright IBM Corp. 2009 * * phyp_driver.c: ssh layer to access Power Hypervisors * * Authors: * Eduardo Otubo * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Em Qua, 2009-05-06 às 09:26 +0200, Daniel Veillard escreveu: > On Mon, May 04, 2009 at 05:50:03PM -0300, Eduardo Otubo wrote: > > Hello DV, > > Hi Eduardo, > > sorry for the delay I took a few days of vacations :-) Hello DV, Nice! Hope you enjoyed your vacations :) > > > > +while (channel && channel_is_open(channel)) { > > > > +ret = channel_read(channel, readbuf, 0, 0); > > > > +if (ret < 0) { > > > > +(*exit_status) = SSH_CHANNEL_READ_ERR; > > > > +break; > > > > +} > > > > + > > > > +if (ret == 0) { > > > > +channel_send_eof(channel); > > > > +while(channel_get_exit_status(channel) == -1){ > > > > +channel_poll(channel,0); > > > > +usleep(50); > > > > +} > > > > > >It's always a bit nasty to sleep like that. Is there really now way > > > to use something like poll or select instead ? In average you're gonna > > > be waken up multiple time while waiting for your answer while the kernel > > > could instead wake you up exactly when you have the data. > > > > This was a libssh issue This was the only way I could make it work. But > > now the libssh is fixed and this function is a little different - > > http://pastebin.com/fbf84426 > > Looks fine now, but how can you make sure libssh used will have the > fix, is there a new version released and the associated test in > configure.in ? In fact I am part of the libssh team, I help them with testing. And yes, we're planning to release a new version of libssh this week with all these fixes. But I still need to make it sure in configure.in. I'll do it right now. > > > > > + > > > > +/* return the lpar_id given a name and a managed system name */ > > > > +static int > > > > +phypGetLparID(SSH_SESSION * ssh_session, const char *managed_system, > > > > + const char *name) > > > > +{ > > > > +int exit_status = 0; > > > > +virBuffer cmd = VIR_BUFFER_INITIALIZER; > > > > + > > > > +virBufferVSprintf(&cmd, > > > > + "lssyscfg -r lpar -m %s --filter lpar_names=%s > > > > -F lpar_id", > > > > + managed_system, name); > > > > +const char *tex_ret = > > > > +__inner_exec_command(ssh_session, > > > > virBufferContentAndReset(&cmd), > > > > + &exit_status); > > > > + > > > > +virBufferContentAndReset(&cmd); > > > > > >Huh ? you're supposed to get the resulting char *, and then free it > > >later once you're done with the data. Here youre just leaking memory > > >I'm afraid > > > > > > same thing for most of the commands in that file. > > > > Here, I just would like to free the Buffer, and this was the best way I > > find since I couldn't find any better function to manipulate this. How > > do I simply free a buffer using the internal virBuffer* API? > > Well you didn't allocate the buffer structure since it's on the heap > and initilized with the VIR_BUFFER_INITIALIZER macro. So technically > you don't need to free it, but you need to free the string in the > buffer. That string is returned by virBufferContentAndReset(), so you > need to save that to a local variable and free it once done. All right, got it. Thanks for the tips :) []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Authentication with virConnectAuthPtr
This sample of code helped me a lot! Here is the phypOpen function I rewrited based on your code: http://pastebin.com/f65912242 - I did a lot of tests with my HMC here and everything seemed to be working fine. The prompt for the password and the use of the public key. I also did use the virRaiseError() to adjust all the error messages into libvirt pattern. the modified function I made based on your sample code. Thanks for the help. []'s Em Ter, 2009-05-05 às 21:50 +0100, Daniel P. Berrange escreveu: > On Tue, May 05, 2009 at 04:06:12PM -0300, Eduardo Otubo wrote: > > Hello all, > > > > I'll start using virConnectAuthPtr to handle the authentication proccess > > at the phyp driver I'm wrinting > > <https://www.redhat.com/archives/libvir-list/2009-April/msg00493.html> > > and I have some doubts in my mind: > > > > 1) What are the types of authentication that 'int *credtype' can hold? > > And who fills it with the information I'll need? > > These are all defined in libvirt.h - we basically copied the SASL > credential types > > VIR_CRED_USERNAME = 1, /* Identity to act as */ > VIR_CRED_AUTHNAME = 2, /* Identify to authorize as */ > VIR_CRED_LANGUAGE = 3, /* RFC 1766 languages, comma separated */ > VIR_CRED_CNONCE = 4, /* client supplies a nonce */ > VIR_CRED_PASSPHRASE = 5, /* Passphrase secret */ > VIR_CRED_ECHOPROMPT = 6, /* Challenge response */ > VIR_CRED_NOECHOPROMPT = 7, /* Challenge response */ > VIR_CRED_REALM = 8,/* Authentication realm */ > VIR_CRED_EXTERNAL = 9, /* Externally managed credential */ > > The client application filles in the data in virConnectAuth struct, > providing the function callback pointer, an opaque data blob (cddata) > and the list of credential types it knows how to handle. > > > 2) Once known the credential type, I need to use the function pointer > > 'virConnectAuthCallbackPtr cb' to get the information whatever it is, > > right? I mean, it can be a password, a pubkey or anything else, right? > > Is there a callback able to handle password or pubkeys? > > Yep, once your driver knows what credentials it needs to collect, it > should check to see if the client has declared it supports the required > credentials. If it does, then the driver should populate an array of > virConnectCredential objects detailing what credentials needs to be > collected. The callback is then invoked, and the client app will collect > the credentials, putting the results in the 'result' / resultlen fields. > > When the callback returns, the driver can get the credentials fro mthe > result/resultlen field - though it should check the callback return > status to see if the client app had any errors. > > > 3) And finally I'll be able to use the 'void *cbdata' to manage the > > authentication in my way. In my case, using libssh. In fact, in the end > > of the process, I'll just need a password or a key to get things > > working. > > The 'cbdata' field is something used by the client app. Both a password > or private key passphrase would map to VIR_CRED_PASSPHRASE credential > type. You'd just have a different prompt / challenge > > > There is no driver authenticatin agaist ssh channel, that's why I got so > > confused with this topic. > > > > I don't know if my thoughts are pretty clear here. But I would like to > > confirm the information 2 and 3, and check how 1 works. Could anyone > > help me? > > Let me give you a close-to-working example that tries to illustrate > the general idea from the driver point of view. > > First off, libvirt.so provides a generic callback that works for command > line based apps, and knows how to collect credentials of type > > static int virConnectCredTypeDefault[] = { > VIR_CRED_AUTHNAME, > VIR_CRED_ECHOPROMPT, > VIR_CRED_REALM, > VIR_CRED_PASSPHRASE, > VIR_CRED_NOECHOPROMPT, > VIR_CRED_EXTERNAL, > }; > > static virConnectAuth virConnectAuthDefault = { > virConnectCredTypeDefault, > sizeof(virConnectCredTypeDefault)/sizeof(int), > virConnectAuthCallbackDefault, > NULL, > }; > > > This is what virsh uses when connecting to libvirt > > ctl->conn = virConnectOpenAuth(ctl->name, virConnectAuthPtrDefault, 0) > > > > Now, in your Phyp driver, lets assume at some point in time libssh tells > it wants a username+password. > > These will map to VIR_CRED_AUTHNAME and VIR_CRED_PASSPHRASE, so first > step is to ensure the callback passed in by the client app supports > these
[libvirt] Authentication with virConnectAuthPtr
Hello all, I'll start using virConnectAuthPtr to handle the authentication proccess at the phyp driver I'm wrinting <https://www.redhat.com/archives/libvir-list/2009-April/msg00493.html> and I have some doubts in my mind: 1) What are the types of authentication that 'int *credtype' can hold? And who fills it with the information I'll need? 2) Once known the credential type, I need to use the function pointer 'virConnectAuthCallbackPtr cb' to get the information whatever it is, right? I mean, it can be a password, a pubkey or anything else, right? Is there a callback able to handle password or pubkeys? 3) And finally I'll be able to use the 'void *cbdata' to manage the authentication in my way. In my case, using libssh. In fact, in the end of the process, I'll just need a password or a key to get things working. There is no driver authenticatin agaist ssh channel, that's why I got so confused with this topic. I don't know if my thoughts are pretty clear here. But I would like to confirm the information 2 and 3, and check how 1 works. Could anyone help me? Thanks in advance, []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Hello DV, I agree with your suggestions and everything is fixed now. But I would like to discuss some points. > > > +while (channel && channel_is_open(channel)) { > > +ret = channel_read(channel, readbuf, 0, 0); > > +if (ret < 0) { > > +(*exit_status) = SSH_CHANNEL_READ_ERR; > > +break; > > +} > > + > > +if (ret == 0) { > > +channel_send_eof(channel); > > +while(channel_get_exit_status(channel) == -1){ > > +channel_poll(channel,0); > > +usleep(50); > > +} > >It's always a bit nasty to sleep like that. Is there really now way > to use something like poll or select instead ? In average you're gonna > be waken up multiple time while waiting for your answer while the kernel > could instead wake you up exactly when you have the data. This was a libssh issue This was the only way I could make it work. But now the libssh is fixed and this function is a little different - http://pastebin.com/fbf84426 > > + > > +/* return the lpar_id given a name and a managed system name */ > > +static int > > +phypGetLparID(SSH_SESSION * ssh_session, const char *managed_system, > > + const char *name) > > +{ > > +int exit_status = 0; > > +virBuffer cmd = VIR_BUFFER_INITIALIZER; > > + > > +virBufferVSprintf(&cmd, > > + "lssyscfg -r lpar -m %s --filter lpar_names=%s -F > > lpar_id", > > + managed_system, name); > > +const char *tex_ret = > > +__inner_exec_command(ssh_session, virBufferContentAndReset(&cmd), > > + &exit_status); > > + > > +virBufferContentAndReset(&cmd); > >Huh ? you're supposed to get the resulting char *, and then free it >later once you're done with the data. Here youre just leaking memory >I'm afraid > > same thing for most of the commands in that file. Here, I just would like to free the Buffer, and this was the best way I find since I couldn't find any better function to manipulate this. How do I simply free a buffer using the internal virBuffer* API? Thanks for the help, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Hello again, I very am glad with all the feedback I got. The following attachtment is the result of the work using all the suggestions the list made. I also have a few comments over this new RFC. Here is a little Changelog: * Now the URI is recognized as phyp://u...@hmc/managed_system. To use path component of the uri struct, I had to implement a little function to strip out the first slash of the string, giving me only 'path', instead of '/path'. * I implemented the option --with-libssh and --with-phyp right according to what Daniel Berrange suggested. * Now all the variable-size string buffers are manipulated with the internal API virBuffer* to make it safer. | +- This made me think and change the __inner_exec_command function. Now it returns char * with all the textual return, and I am passing int * as reference to get the exit status - all the information I need about the remote executed command. | +- And this also made me write a little auxiliar function to strip out the '\n' from the textual return. Known and unsolved issues: * Authentication - need to improve the authenticantion as Daniel Berrange said. Still in progress. * Error codes. * Logging and debugging messages. Any comments are welcome, []'s Em Sex, 2009-03-20 às 13:58 -0300, Eduardo Otubo escreveu: > Hello all, > > I've been working on a libvirt extension to manage IBM's Power VMs > (LPARs). The Power systems are managed through management console > referred to as the HMC or using a management partition (IVM). Both HMC > and IVM runs an SSH, then you can reach it via command line, and an HTTP > server, then you can reach it via web browser. > > The protocol between the console and the partition (LPAR) is not > disclosed, therefore I propose the driver to execute commands remoetly > over an SSH connection to the consoles to manage IBM LPARs. > > The patch attached is the first scratch of the driver that will interact > with HMC over a SSH connection. The URI model that is > used in virsh command line is: > > virsh --conect phyp://$u...@$server > > Some known issues are: > * Next step is to make the URI like this: phyp://$user@ > $HMC/@managed_system. Almost finished. What it takes now is > $server = $HMC = $managed_system. > * Next features in my TODO list are "resume", "stop" and "reboot" the > LPAR. > > Any comments are welcome. > > Thanks, > > > -- > Libvir-list mailing list > Libvir-list@redhat.com > https://www.redhat.com/mailman/listinfo/libvir-list -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com diff --git a/configure.in b/configure.in index dcacc7f..9545a20 100644 --- a/configure.in +++ b/configure.in @@ -182,6 +182,10 @@ AC_ARG_WITH([uml], [ --with-uml add UML support (on)],[],[with_uml=yes]) AC_ARG_WITH([openvz], [ --with-openvz add OpenVZ support (on)],[],[with_openvz=yes]) +AC_ARG_WITH([libssh], +[ --with-libssh=[PFX] libssh location],[],[with_libssh=yes]) +AC_ARG_WITH([phyp], +[ --with-phyp=[PFX] add PHYP support (on)],[with_phyp=yes],[with_phyp=check]) AC_ARG_WITH([vbox], [ --with-vbox add VirtualBox support (on)],[],[with_vbox=yes]) AC_ARG_WITH([lxc], @@ -729,6 +733,51 @@ AM_CONDITIONAL([HAVE_NUMACTL], [test "$with_numactl" != "no"]) AC_SUBST([NUMACTL_CFLAGS]) AC_SUBST([NUMACTL_LIBS]) +if test "$with_libssh" != "yes" -a "$with_libssh" != "no"; then + libssh_path="$with_libssh" +elif test "$with_libssh" = "yes"; then + libssh_path="/usr/local/lib/" +elif test "$with_libssh" = "no"; then + with_phyp="no"; +fi + +if test "$with_phyp" = "check"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +with_phyp="no" + with_libssh="no"; +],[]) + + if test "$with_phyp" != "no"; then + AC_CHECK_HEADERS([libssh/libssh.h],[ + with_phyp="yes" +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +],[ +with_phyp="no" + with_libssh="no"; +],[]) + fi +elif test "$with_phyp" = "yes"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L$libssh_path" +AC_SUBST([LIBSSH_LIBS])],[ +AC_MSG_ERROR([You must install the libssh to compile Phype driver.]) +]) + + AC_CHECK_HEADERS([libssh/libssh.h],[ +LIBSSH_CFLAGS=&q
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Hello Daniel, I've been talking to libssh guys and they did a lot of changes trying to be more compliant. What do you think about reconsidering the use of libssh instead of libssh2? > Hmm, I hadn't come across libssh before. To be honest I'm not really > all that impressed with the code quality of libssh. There is a serious > lack of basic error checking in system calls & libc calls they make, > in particular no malloc() call is ever checked for failure. It's fixed in svn trunk now. > It is > hardcoded to use IPv4 for sockets. This issue is solved since at least one year ago. > It is not const-correct in its > API usage, or its exposed public API. This is being fixed and it's almost done. > > As such I don't think libssh is suitable for use in libvirt, and would > rather this used libssh2. libssh2 also has the benefit that it has > been ported to Win32 platform already. Libssh is ported to win32 and works very fine. > > As for SSH v1 protocol support, this is a flawed protocol and should not > be used in any apps or libraries anymore because it cannot be considered > secure by modern standards. In their words "can't agree more with him. SSH1 support was made initialy to support old cisco routers". All of these issues will be available in the libssh-0.3, which will be released in the end of this week, 10/april. Do you think after all these changes libssh will be compliant to be used in libvirt? What do you think? []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Hello Daniel, Look, I don't want to make big deal about this, I'll just answer these points below with some arguments they gave me. If we find out libssh2 is better, I' can change it, no problem at all. > > In fact I use libssh <http://0xbadc0de.be/wiki/libssh:libssh> and not > > libssh2. I choosed libssh instead of libssh2 for some reasons: libssh2 > > doesn't handle server side ssh or sshv1. And I am more used to work with > > its API then libssh2. > > Hmm, I hadn't come across libssh before. To be honest I'm not really > all that impressed with the code quality of libssh. There is a serious > lack of basic error checking in system calls & libc calls they make, > in particular no malloc() call is ever checked for failure. It is Yes, malloc() error checking is a known issue and they're already working on it. > hardcoded to use IPv4 for sockets. They told me they did some tests with IPv6 and worked perfectly. > It is not const-correct in its > API usage, or its exposed public API. Yes, that's a point. But I think it's purely coding style. > As such I don't think libssh is suitable for use in libvirt, and would > rather this used libssh2. libssh2 also has the benefit that it has > been ported to Win32 platform already. > > As for SSH v1 protocol support, this is a flawed protocol and should not > be used in any apps or libraries anymore because it cannot be considered > secure by modern standards. I see no problem on changing my code to libssh2, I may change it and send another patch/rfc. Regards, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
given > - diable the phyp driver Yes, I agree with this. I'll implement this way and post it back. > > + > > dnl virsh libraries > > AC_CHECK_HEADERS([readline/readline.h]) > > > > @@ -1345,6 +1362,7 @@ AC_MSG_NOTICE([QEMU: $with_qemu]) > > AC_MSG_NOTICE([ UML: $with_uml]) > > AC_MSG_NOTICE([ OpenVZ: $with_openvz]) > > AC_MSG_NOTICE([ LXC: $with_lxc]) > > +AC_MSG_NOTICE([ IBM HMC/IVM: $with_phyp]) > > AC_MSG_NOTICE([Test: $with_test]) > > AC_MSG_NOTICE([ Remote: $with_remote]) > > AC_MSG_NOTICE([ Network: $with_network]) > > Can you either shortern this to just 'Phyp: $with_phyp', or > fix the indentation for all the other existing lines here, > so everything is aligned sensibly. Sure, in fact, I think IBM HMC/IVM is too high level. The final use of this feature does not need this details. Phyp is enough information we will need. > > > diff --git a/src/phyp_conf.h b/src/phyp_conf.h > > new file mode 100644 > > index 000..51ca65e > > --- /dev/null > > +++ b/src/phyp_conf.h > > @@ -0,0 +1,44 @@ > > +/* > > + * Copyright IBM Corp. 2009 > > + * > > + * phyp_driver.c: ssh layer to access Power Hypervisors > > + * > > + * Authors: > > + * Eduardo Otubo > > + * > > + * This library is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * This library is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General Public > > + * License along with this library; if not, write to the Free Software > > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > > + */ > > + > > +#include > > +#include > > This should typically be done in the .c file, rather than the .h files. Ok, this minor fixes will be at next version of this patch. > > +static virDrvOpenStatus > > +phypOpen(virConnectPtr conn, > > + virConnectAuthPtr auth ATTRIBUTE_UNUSED, > > + int flags ATTRIBUTE_UNUSED) > > +{ > > +if (!conn || !conn->uri) > > +return VIR_DRV_OPEN_DECLINED; > > + > > +if (conn->uri->scheme == NULL || conn->uri->server == NULL) > > +return VIR_DRV_OPEN_DECLINED; > > + > > +int ssh_auth = 0, exit_status = 0; > > +char *banner; > > +char *password; > > + > > +SSH_SESSION *session; > > +SSH_OPTIONS *opt; > > Our general coding style is to keep the variabl declarations at > the start of the nearest enclosing {} block. So either at start > of the function, or start of the while/if/for loop. Ok, I am still getting used to your coding style. I read the HACKING file and followed all steps and details strictly, but some gone missing like this. Will fix and also will be in the next version. > > > + > > +session = ssh_new(); > > +opt = ssh_options_new(); > > + > > +if (!conn->uri->port) > > +conn->uri->port = 22; > > + > > +/*setting some ssh options */ > > +ssh_options_set_host(opt, conn->uri->server); > > +ssh_options_set_port(opt, conn->uri->port); > > +ssh_options_set_username(opt, conn->uri->user); > > +ssh_set_options(session, opt); > > + > > +/*starting ssh connection */ > > +if (ssh_connect(session)) { > > +fprintf(stderr, "Connection failed : %s\n", > > +ssh_get_error(session)); > > +ssh_disconnect(session); > > +ssh_finalize(); > > +exit_status = SSH_CONN_ERR; > > +return VIR_DRV_OPEN_DECLINED; > > +} > > + > > +/*trying to use pub key */ > > +if ((ssh_auth = > > + ssh_userauth_autopubkey(session, NULL)) == SSH_AUTH_ERROR) { > > +fprintf(stderr, "Authenticating with pubkey: %s\n", > > +ssh_get_error(session)); > > +exit_status = SSH_AUTH_PUBKEY_ERR; > > +return VIR_DRV_OPEN_DECLINED; > > +} > > + > > +if ((banner = ssh_get_issue_banner(session))) { > > +printf("%s\
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Hello Kaitlin, > > +#include "domain_conf.h" > > +/* Main driver state */ > > +typedef struct __phyp_driver phyp_driver_t; > > +struct __phyp_driver { > > +virMutex lock; > > + > > +virCapsPtr *caps; > > + > > +virDomainObjList *domains; > > + > > +char *configDir; > > +char *autostartDir; > > +char *stateDir; > > +char *logDir; > > +int have_netns; > > +}; > > I don't see this struct / typedef being used anywhere. Will this be > used for something in the future? I am still planning how I should store all driver information, so I think I should keep this for now. > > > > +static int > > +phypListDomains(virConnectPtr conn, int *ids, int nids) > > +{ > > +SSH_SESSION *ssh_session = conn->privateData; > > +const char *managed_system = conn->uri->server; > > +int ret = 0; > > +char id_c[10]; > > +unsigned int i = 0, j = 0; > > +char *cmd; > > +char *textual_return; > > + > > +if (VIR_ALLOC_N(cmd, MAXSIZE+sizeof(managed_system))) { > > +return PHYP_NO_MEM; > > +} > > + > > +if (VIR_ALLOC_N(textual_return, MAXSIZE)) { > > +return PHYP_NO_MEM; > > +} > > + > > +nids = 0; > > + > > +memset(id_c, 0, 10); > > +sprintf(cmd, "lssyscfg -r lpar -m %s -F lpar_id", managed_system); > > +ret = __inner_exec_command(ssh_session, cmd, textual_return); > > You don't check ret to see if an error occured. Already fixed, but thanks anyway. > > > +static virDomainPtr > > +phypDomainLookupByID(virConnectPtr conn, int lpar_id) > > +{ > > +SSH_SESSION *ssh_session = conn->privateData; > > +virDomainPtr dom = NULL; > > +const char *managed_system = conn->uri->server; > > +char *lpar_name; > > +unsigned char *lpar_uuid; > > Any reason not to use a virDomainObjPtr to hold these values? Good point. I should follow the patterns and start using virDomainObj to store name and uuid. But unfortunately ssh_session and the managed_system name I still need to keep them as I did. > > > > + > > +if (VIR_ALLOC_N(lpar_name, 100 * sizeof(char))) > > +return NULL; > > + > > +if (VIR_ALLOC_N(lpar_uuid, 100 * sizeof(char))) > > +return NULL; > > You then wouldn't need to use a magic number here. You could just do an > alloc of the virDomainObjPtr object itself. Yes, this problem will be solved when I change it to virDomainObj. Thanks again for the comments. []'s -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Power Hypervisor Libvirt support
Sorry all about my last email, the subject should be "[RFC] Power Hypervisor Libvirt support". There should be an error here. Thanks again, Em Sex, 2009-03-20 às 13:58 -0300, Eduardo Otubo escreveu: > Hello all, > > I've been working on a libvirt extension to manage IBM's Power VMs > (LPARs). The Power systems are managed through management console > referred to as the HMC or using a management partition (IVM). Both HMC > and IVM runs an SSH, then you can reach it via command line, and an HTTP > server, then you can reach it via web browser. > > The protocol between the console and the partition (LPAR) is not > disclosed, therefore I propose the driver to execute commands remoetly > over an SSH connection to the consoles to manage IBM LPARs. > > The patch attached is the first scratch of the driver that will interact > with HMC over a SSH connection. The URI model that is > used in virsh command line is: > > virsh --conect phyp://$u...@$server > > Some known issues are: > * Next step is to make the URI like this: phyp://$user@ > $HMC/@managed_system. Almost finished. What it takes now is > $server = $HMC = $managed_system. > * Next features in my TODO list are "resume", "stop" and "reboot" the > LPAR. > > Any comments are welcome. > > Thanks, > > > -- > Libvir-list mailing list > Libvir-list@redhat.com > https://www.redhat.com/mailman/listinfo/libvir-list -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] (no subject)
Hello all, I've been working on a libvirt extension to manage IBM's Power VMs (LPARs). The Power systems are managed through management console referred to as the HMC or using a management partition (IVM). Both HMC and IVM runs an SSH, then you can reach it via command line, and an HTTP server, then you can reach it via web browser. The protocol between the console and the partition (LPAR) is not disclosed, therefore I propose the driver to execute commands remoetly over an SSH connection to the consoles to manage IBM LPARs. The patch attached is the first scratch of the driver that will interact with HMC over a SSH connection. The URI model that is used in virsh command line is: virsh --conect phyp://$u...@$server Some known issues are: * Next step is to make the URI like this: phyp://$user@ $HMC/@managed_system. Almost finished. What it takes now is $server = $HMC = $managed_system. * Next features in my TODO list are "resume", "stop" and "reboot" the LPAR. Any comments are welcome. Thanks, -- Eduardo Otubo Software Engineer Linux Technology Center IBM Systems & Technology Group Mobile: +55 19 8135 0885 ot...@linux.vnet.ibm.com diff --git a/configure.in b/configure.in index 6b2bb5e..201a7dc 100644 --- a/configure.in +++ b/configure.in @@ -182,6 +182,8 @@ AC_ARG_WITH([uml], [ --with-uml add UML support (on)],[],[with_uml=yes]) AC_ARG_WITH([openvz], [ --with-openvz add OpenVZ support (on)],[],[with_openvz=yes]) +AC_ARG_WITH([phyp], +[ --with-phyp add IBM HMC/IVM support (on)],[],[with_phyp=yes]) AC_ARG_WITH([lxc], [ --with-lxc add Linux Container support (on)],[],[with_lxc=yes]) AC_ARG_WITH([test], @@ -714,6 +716,21 @@ AM_CONDITIONAL([HAVE_NUMACTL], [test "$with_numactl" != "no"]) AC_SUBST([NUMACTL_CFLAGS]) AC_SUBST([NUMACTL_LIBS]) +if test "$with_phyp" = "yes"; then + AC_CHECK_LIB([ssh],[ssh_new],[ +LIBSSH_LIBS="$LIBSSH_LIBS -lssh -L/usr/local/lib/" +AC_SUBST([LIBSSH_LIBS])],[ +AC_MSG_ERROR([You must install the libssh to compile Phype driver.])]) + + AC_CHECK_HEADERS([libssh/libssh.h],[ +LIBSSH_CFLAGS="-I/usr/local/include/libssh" +AC_SUBST([LIBSSH_CFLAGS])],[ +AC_MSG_ERROR([Cannot find libssh headers.Is libssh installed ?])],[]) + AC_DEFINE_UNQUOTED([WITH_PHYP], 1, +[whether IBM HMC / IVM driver is enabled]) +fi +AM_CONDITIONAL([WITH_PHYP],[test "$with_phyp" = "yes"]) + dnl virsh libraries AC_CHECK_HEADERS([readline/readline.h]) @@ -1345,6 +1362,7 @@ AC_MSG_NOTICE([QEMU: $with_qemu]) AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([ LXC: $with_lxc]) +AC_MSG_NOTICE([ IBM HMC/IVM: $with_phyp]) AC_MSG_NOTICE([Test: $with_test]) AC_MSG_NOTICE([ Remote: $with_remote]) AC_MSG_NOTICE([ Network: $with_network]) @@ -1373,6 +1391,7 @@ fi AC_MSG_NOTICE([]) AC_MSG_NOTICE([Libraries]) AC_MSG_NOTICE([]) +AC_MSG_NOTICE([ libssh: $LIBSSH_CFLAGS $LIBSSH_LIBS]) AC_MSG_NOTICE([ libxml: $LIBXML_CFLAGS $LIBXML_LIBS]) AC_MSG_NOTICE([ gnutls: $GNUTLS_CFLAGS $GNUTLS_LIBS]) if test "$with_sasl" != "no" ; then diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 2c3777d..a61e2f3 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -61,6 +61,7 @@ typedef enum { VIR_FROM_UML, /* Error at the UML driver */ VIR_FROM_NODEDEV, /* Error from node device monitor */ VIR_FROM_XEN_INOTIFY, /* Error from xen inotify layer */ +VIR_FROM_PHYP, /* Error from IBM power hypervisor */ VIR_FROM_SECURITY, /* Error from security framework */ } virErrorDomain; diff --git a/src/Makefile.am b/src/Makefile.am index d5aac11..787dc37 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ INCLUDES = \ -I../include \ -...@top_srcdir@/include \ -...@top_srcdir@/qemud \ + $(LIBSSH_CFLAGS) \ $(LIBXML_CFLAGS) \ $(XEN_CFLAGS) \ $(SELINUX_CFLAGS) \ @@ -125,6 +126,10 @@ LXC_CONTROLLER_SOURCES = \ veth.c veth.h \ cgroup.c cgroup.h +PHYP_DRIVER_SOURCES = \ + phyp_conf.c phyp_conf.h \ + phyp_driver.c phyp_driver.h + OPENVZ_DRIVER_SOURCES = \ openvz_conf.c openvz_conf.h \ openvz_driver.c openvz_driver.h @@ -255,6 +260,18 @@ endif libvirt_driver_xen_la_SOURCES = $(XEN_DRIVER_SOURCES) endif +if WITH_PHYP +if WITH_DRIVER_MODULES +mod_LTLIBRARIES += libvirt_driver_phyp.la +else +noinst_LTLIBRARIES += libvirt_driver_phyp.la +libvirt_la_LIBADD += libvirt_driver_phyp.la +endif +libvirt_driver_phyp_la_LDFLAGS = $(LIBSSH_LIBS) +libvirt_driver_phyp_la_CFLAGS = $(LIBSSH_CFLAGS) +libvirt_driver_phyp_la_SOURCES = $(PHYP_DRIVER_SOURCES) +endif + if WITH_OPENVZ if WITH_DRIVER_MODULES mod_LTLIBRARIES += libvirt_d