From gesaint at linux.vnet.ibm.com Thu Aug 1 01:27:29 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Thu, 1 Aug 2013 09:27:29 +0800 Subject: [Libvirt-cim] [PATCH] Add default network card existence checking Message-ID: <1375320449-22373-1-git-send-email-gesaint@linux.vnet.ibm.com> From: Xu Wang The default network card (used as forward device in network pool) name was set as "eth0" in Virt_SettingDefineCapabilities.c. This patch added check if there is such a network card exists in the network info list. If it exists, use it. If not, the default network card would be changed into the first available one except lo. Signed-off-by: Xu Wang --- libxkutil/misc_util.c | 38 +++++++++++++++++++++++++++++++++ libxkutil/misc_util.h | 2 +- src/Virt_SettingsDefineCapabilities.c | 8 ++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 9e7e0d5..ada664c 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -900,6 +900,44 @@ int virt_set_status(const CMPIBroker *broker, return ret; } +char *get_avai_net(char *def_name) +{ + char buf[512]; + FILE *pp; + char *delims = ": "; + char *sub_str = NULL; + char *avai_net = NULL; + bool avai_found = false; + + pp = popen("ip addr", "r"); + if (!pp) { + CU_DEBUG("popen() error.\n"); + return NULL; + } + + while (fgets(buf, sizeof(buf), pp)) { + sub_str = strtok(buf, delims); + while (sub_str != NULL) { + if (!strncmp(sub_str, "eth", 3) || !strncmp(sub_str, "em", 2)) { + if (!strcmp(def_name, sub_str)) { + avai_net = strdup(sub_str); + goto out; + } + + if (!avai_found) { + avai_net = strdup(sub_str); + avai_found = true; + } + } + sub_str = strtok(NULL, delims); + } + } + pclose(pp); + +out: + return avai_net; +} + /* * Local Variables: diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h index fd4f191..fc63000 100644 --- a/libxkutil/misc_util.h +++ b/libxkutil/misc_util.h @@ -157,7 +157,7 @@ const char *get_mig_ssh_tmp_key(void); bool get_disable_kvm(void); const char *get_lldptool_query_options(void); const char *get_vsi_support_key_string(void); - +char *get_avai_net(char *def_name); /* * Local Variables: * mode: C diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c index 78c128c..09ae49f 100644 --- a/src/Virt_SettingsDefineCapabilities.c +++ b/src/Virt_SettingsDefineCapabilities.c @@ -777,6 +777,7 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, int dev_count; int i; char *tmp_str = NULL; + char *forward_device = "eth0"; /* Isolated network pools don't have a forward device */ if (pool_type == NETPOOL_FORWARD_NONE) @@ -836,8 +837,13 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, (CMPIValue *)&pool_type, CMPI_uint16); if (i == 1) { + forward_device = get_avai_net(forward_device); + if (!forward_device) { + goto out; + } + CMSetProperty(inst, "ForwardDevice", - (CMPIValue *)"eth0", CMPI_chars); + (CMPIValue *)forward_device, CMPI_chars); } inst_list_add(list, inst); -- 1.7.1 From gesaint at linux.vnet.ibm.com Thu Aug 1 02:08:40 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Thu, 1 Aug 2013 10:08:40 +0800 Subject: [Libvirt-cim] [PATCH 0/2] Add default network card name existence check Message-ID: <1375322922-22761-1-git-send-email-gesaint@linux.vnet.ibm.com> Some default name of network cards is set as "eth0", "eth1" or "em1". But when some system doesn't contain such a name, the testcase would fail. Hence these patches added check of default network card and if it doesn't exists in the network info list, the default name would be changed into the first one except "lo". The second patch is updated with default network card check in libvirt-cim. Xu Wang (2): cimtest: Add default network existence check to 28_definesystem_with_vsi_profile.py cimtest: Add default network existence check to 06_parent_net_pool.py .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 16 +++++++++++++--- .../28_definesystem_with_vsi_profile.py | 9 +++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) From gesaint at linux.vnet.ibm.com Thu Aug 1 02:08:41 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Thu, 1 Aug 2013 10:08:41 +0800 Subject: [Libvirt-cim] [PATCH 1/2] cimtest: Add default network existence check to 28_definesystem_with_vsi_profile.py In-Reply-To: <1375322922-22761-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375322922-22761-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1375322922-22761-2-git-send-email-gesaint@linux.vnet.ibm.com> From: Xu Wang The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list except lo. Signed-off-by: Xu Wang --- .../28_definesystem_with_vsi_profile.py | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py index 2b108f9..a901ae7 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py @@ -33,6 +33,7 @@ # import sys +import os from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS, SKIP, XFAIL_RC, XFAIL from VirtLib import utils @@ -188,6 +189,14 @@ def main(): if rc == 0: vsi_defaults['SourceDevice'] = "em1" + # The default device name may not named 'eth1' or 'em1' so this case would + # return FAIL. The following code will check if default device exists in + # the network card list and if not, source_dev will be changed into the 1st + # network card in the list. + net_info = os.popen('ip addr').read() + if net_info.find(vsi_defaults['SourceDevice']) == -1: + vsi_defaults['SourceDevice'] = net_info.split(': ')[3] + nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData') status = FAIL cxml = None -- 1.7.1 From gesaint at linux.vnet.ibm.com Thu Aug 1 02:08:42 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Thu, 1 Aug 2013 10:08:42 +0800 Subject: [Libvirt-cim] [PATCH 2/2] cimtest: Add default network existence check to 06_parent_net_pool.py In-Reply-To: <1375322922-22761-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375322922-22761-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1375322922-22761-3-git-send-email-gesaint@linux.vnet.ibm.com> From: Xu Wang The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list except lo. Signed-off-by: Xu Wang --- .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py index 2c1f285..5f330e1 100644 --- a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py +++ b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py @@ -39,7 +39,7 @@ # -Netmask="255.255.255.0" # -IPRangeStart="192.168.122.2" # -IPRangeEnd="192.168.122.254" -# -ForwardDevice= [ verified for 'None' and "eth0" ] +# -ForwardDevice= [ verified for 'None' and network card name (default is 'eth0') ] # -ForwardMode=0 [ verified for 1,2 as well ] # # @@ -47,6 +47,7 @@ # Date : 18-05-2009 import sys +import os from sets import Set from CimTest.Globals import logger from XenKvmLib.const import do_main @@ -67,6 +68,15 @@ def main(): options = main.options virt = options.virt server = options.ip + net_dev = 'eth0' + + # The default device name may not named 'eth0', so this case would + # return FAIL. The following code will check if default device exists in + # the network card list and if not, source_dev will be changed into the 1st + # network card in the list. + net_info = os.popen('ip addr').read() + if net_info.find(net_dev) == -1: + net_dev = net_info.split(': ')[3] status, netpool_rasd = get_pool_rasds(server, virt, filter_default=False) if status != PASS: @@ -80,8 +90,8 @@ def main(): 'IPRangeStart' : "192.168.122.2", 'IPRangeEnd' : "192.168.122.254" } - exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), - ('None', 2L), ('eth0', 2L)] + exp_mode_device = [('None', 0L), ('None', 1L), (net_dev, 1L), + ('None', 2L), (net_dev, 2L)] for inst_type in inst_list: logger.info("Verifying '%s' records", inst_type) -- 1.7.1 From jmiao at redhat.com Sat Aug 3 08:01:28 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Sat, 3 Aug 2013 16:01:28 +0800 Subject: [Libvirt-cim] [PATCH] fix xmt-makefv.sh die() output Message-ID: <1375516888-12593-1-git-send-email-jmiao@redhat.com> If xmt-makefv.sh failed, it will prompt FAILED: . But the reason part is blank. It is because die() in xmt-makefv.sh use $i to show the reason. That should be $1 rather than $i. Signed-off-by: Jincheng Miao --- suites/libvirt-cim/images/xmt-makefv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suites/libvirt-cim/images/xmt-makefv.sh b/suites/libvirt-cim/images/xmt-makefv.sh index 64ca362..1cf6a0f 100755 --- a/suites/libvirt-cim/images/xmt-makefv.sh +++ b/suites/libvirt-cim/images/xmt-makefv.sh @@ -31,7 +31,7 @@ else fi die() { - echo "FAILED: $i" >&2 + echo "FAILED: $1" >&2 umount $TMPMOUT >/dev/null 2>&1 kpartx -d $loop >/dev/null 2>&1 -- 1.8.3.1 From jmiao at redhat.com Sat Aug 3 08:14:33 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Sat, 3 Aug 2013 04:14:33 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] fix xmt-makefv.sh die() output In-Reply-To: <1375516888-12593-1-git-send-email-jmiao@redhat.com> References: <1375516888-12593-1-git-send-email-jmiao@redhat.com> Message-ID: <1806371988.10855169.1375517673855.JavaMail.root@redhat.com> Sorry, I forget to identify this is for cimtest. ----- Original Message ----- > From: "Jincheng Miao" > To: libvirt-cim at redhat.com > Cc: "Jincheng Miao" > Sent: Saturday, August 3, 2013 4:01:28 PM > Subject: [Libvirt-cim][PATCH] fix xmt-makefv.sh die() output > > If xmt-makefv.sh failed, it will prompt FAILED: . But the reason part > is blank. It is because die() in xmt-makefv.sh use $i to show the reason. > That > should be $1 rather than $i. > > Signed-off-by: Jincheng Miao > --- > suites/libvirt-cim/images/xmt-makefv.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/suites/libvirt-cim/images/xmt-makefv.sh > b/suites/libvirt-cim/images/xmt-makefv.sh > index 64ca362..1cf6a0f 100755 > --- a/suites/libvirt-cim/images/xmt-makefv.sh > +++ b/suites/libvirt-cim/images/xmt-makefv.sh > @@ -31,7 +31,7 @@ else > fi > > die() { > - echo "FAILED: $i" >&2 > + echo "FAILED: $1" >&2 > > umount $TMPMOUT >/dev/null 2>&1 > kpartx -d $loop >/dev/null 2>&1 > -- > 1.8.3.1 > > From jmiao at redhat.com Sat Aug 3 16:14:17 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Sun, 4 Aug 2013 00:14:17 +0800 Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation Message-ID: <1375546457-2946-1-git-send-email-jmiao@redhat.com> Parted-3.1 remove mkpartfs capability. When generating guest images, it should use external tools (like mke2fs) to create filesystem. Signed-off-by: Jincheng Miao --- suites/libvirt-cim/images/xmt-makefv.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/suites/libvirt-cim/images/xmt-makefv.sh b/suites/libvirt-cim/images/xmt-makefv.sh index 1cf6a0f..85a340c 100755 --- a/suites/libvirt-cim/images/xmt-makefv.sh +++ b/suites/libvirt-cim/images/xmt-makefv.sh @@ -51,7 +51,7 @@ partition() { local file=$1 $PARTED $file mklabel msdos - $PARTED $file mkpartfs primary ext2 0 $(($SIZE - 1)) + $PARTED $file mkpart primary ext2 0 $(($SIZE - 1)) } mount_partition() { @@ -62,7 +62,10 @@ mount_partition() { losetup /dev/$loopdev $file || die "Failed to losetup $file" kpartx -a /dev/$loopdev || die "Failed to kpartx $loopdev" + sleep 2 + mke2fs -t ext2 /dev/mapper/${loopdev}p1 >/dev/null 2>&1 || die "Failed to mkfs ${loopdev}p1" tune2fs -j /dev/mapper/${loopdev}p1 >/dev/null 2>&1|| die "Failed to add journal" + sleep 2 mount /dev/mapper/${loopdev}p1 $TMPMOUNT || die "Failed to mount ${loopdev}p1" echo $loopdev -- 1.8.3.1 From jferlan at redhat.com Tue Aug 6 19:13:11 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 06 Aug 2013 15:13:11 -0400 Subject: [Libvirt-cim] [PATCH] Add default network card existence checking In-Reply-To: <1375320449-22373-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375320449-22373-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <52014AC7.9060405@redhat.com> On 07/31/2013 09:27 PM, Xu Wang wrote: > From: Xu Wang > > The default network card (used as forward device in network pool) name > was set as "eth0" in Virt_SettingDefineCapabilities.c. This patch added > check if there is such a network card exists in the network info list. > If it exists, use it. If not, the default network card would be changed > into the first available one except lo. s/except/accept/ As an aside, generally speaking going through a list of output could be a lengthy process and does have side affects. I would think there'd be a way using perhaps socket/bind/getsockname in order to determine the NIC in use on the host. It just seems there has to be a better way than the loop and compare. > > Signed-off-by: Xu Wang > --- > libxkutil/misc_util.c | 38 +++++++++++++++++++++++++++++++++ > libxkutil/misc_util.h | 2 +- > src/Virt_SettingsDefineCapabilities.c | 8 ++++++- > 3 files changed, 46 insertions(+), 2 deletions(-) > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > index 9e7e0d5..ada664c 100644 > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -900,6 +900,44 @@ int virt_set_status(const CMPIBroker *broker, > return ret; > } > > +char *get_avai_net(char *def_name) s/avai/avail/ ?? I think this would change throughout the function s/char *def_name/const char* def_name/ > +{ > + char buf[512]; > + FILE *pp; > + char *delims = ": "; > + char *sub_str = NULL; > + char *avai_net = NULL; > + bool avai_found = false; > + > + pp = popen("ip addr", "r"); > + if (!pp) { > + CU_DEBUG("popen() error.\n"); > + return NULL; > + } > + > + while (fgets(buf, sizeof(buf), pp)) { > + sub_str = strtok(buf, delims); > + while (sub_str != NULL) { > + if (!strncmp(sub_str, "eth", 3) || !strncmp(sub_str, "em", 2)) { > + if (!strcmp(def_name, sub_str)) { if (avai_found) free(avai_net); > + avai_net = strdup(sub_str); > + goto out; > + } > + > + if (!avai_found) { > + avai_net = strdup(sub_str); > + avai_found = true; > + } > + } > + sub_str = strtok(NULL, delims); > + } > + } > + pclose(pp); This should move to after out: ; otherwise, we leak pp when we goto out above. > + > +out: > + return avai_net; > +} > + > > /* > * Local Variables: > diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h > index fd4f191..fc63000 100644 > --- a/libxkutil/misc_util.h > +++ b/libxkutil/misc_util.h > @@ -157,7 +157,7 @@ const char *get_mig_ssh_tmp_key(void); > bool get_disable_kvm(void); > const char *get_lldptool_query_options(void); > const char *get_vsi_support_key_string(void); > - > +char *get_avai_net(char *def_name); s/char *def_name/const char *def_name) > /* > * Local Variables: > * mode: C > diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c > index 78c128c..09ae49f 100644 > --- a/src/Virt_SettingsDefineCapabilities.c > +++ b/src/Virt_SettingsDefineCapabilities.c > @@ -777,6 +777,7 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, > int dev_count; > int i; > char *tmp_str = NULL; > + char *forward_device = "eth0"; s/"eth0"/NULL/ > > /* Isolated network pools don't have a forward device */ > if (pool_type == NETPOOL_FORWARD_NONE) > @@ -836,8 +837,13 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, > (CMPIValue *)&pool_type, CMPI_uint16); > > if (i == 1) { > + forward_device = get_avai_net(forward_device); s/(forward_device)/("eth0") > + if (!forward_device) { > + goto out; > + } > + > CMSetProperty(inst, "ForwardDevice", > - (CMPIValue *)"eth0", CMPI_chars); > + (CMPIValue *)forward_device, CMPI_chars); I think you should free(forward_device) here > } > > inst_list_add(list, inst); > From jferlan at redhat.com Tue Aug 6 23:57:29 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 06 Aug 2013 19:57:29 -0400 Subject: [Libvirt-cim] [PATCH 2/2] cimtest: Add default network existence check to 06_parent_net_pool.py In-Reply-To: <1375322922-22761-3-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375322922-22761-1-git-send-email-gesaint@linux.vnet.ibm.com> <1375322922-22761-3-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <52018D69.30107@redhat.com> On 07/31/2013 10:08 PM, Xu Wang wrote: > From: Xu Wang > > The default network card name is 'eth0' or 'em1'. But if the network > card name doesn't contain those values, error would occur. So this patch > will check if the default network card name exists in the network > card name list. If not, the network card name would changed into > the first one in the network card name list except lo. > > Signed-off-by: Xu Wang > --- > .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 16 +++++++++++++--- > 1 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py > index 2c1f285..5f330e1 100644 > --- a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py > +++ b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py > @@ -39,7 +39,7 @@ > # -Netmask="255.255.255.0" > # -IPRangeStart="192.168.122.2" > # -IPRangeEnd="192.168.122.254" > -# -ForwardDevice= [ verified for 'None' and "eth0" ] > +# -ForwardDevice= [ verified for 'None' and network card name (default is 'eth0') ] > # -ForwardMode=0 [ verified for 1,2 as well ] > # > # > @@ -47,6 +47,7 @@ > # Date : 18-05-2009 > > import sys > +import os > from sets import Set > from CimTest.Globals import logger > from XenKvmLib.const import do_main > @@ -67,6 +68,15 @@ def main(): > options = main.options > virt = options.virt > server = options.ip > + net_dev = 'eth0' > + > + # The default device name may not named 'eth0', so this case would > + # return FAIL. The following code will check if default device exists in > + # the network card list and if not, source_dev will be changed into the 1st > + # network card in the list. > + net_info = os.popen('ip addr').read() > + if net_info.find(net_dev) == -1: > + net_dev = net_info.split(': ')[3] > > status, netpool_rasd = get_pool_rasds(server, virt, filter_default=False) > if status != PASS: > @@ -80,8 +90,8 @@ def main(): > 'IPRangeStart' : "192.168.122.2", > 'IPRangeEnd' : "192.168.122.254" > } > - exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), > - ('None', 2L), ('eth0', 2L)] > + exp_mode_device = [('None', 0L), ('None', 1L), (net_dev, 1L), > + ('None', 2L), (net_dev, 2L)] 'git am' gives a warning about extraneous whitespace... Thus... s/1L), /1L),/ Beyond that - this test fails for me: RASD - 06_parent_net_pool.py: FAIL ERROR - Exception details: Mismatching Mode and device values, Got [('None', 0L), ('None', 1L), ('em1', 1L), ('None', 2L), ('em1', 2L)], Expected [('None', 0L), ('None', 1L), ('eth0', 1L), ('None', 2L), ('eth0', 2L)] -------------------------------------------------------------------- It doesn't matter what I initialize 'net_dev' to (em1, foobar, etc), the filling of 'n_rec' returns eth0. I wasn't able to directly run the wbemcli command in the comments to the code, but it seems from reading the libvirt-cim code: "src/Virt_SettingsDefineCapabilities.c" set_net_pool_props(): if (i == 1) { CMSetProperty(inst, "ForwardDevice", (CMPIValue *)"eth0", CMPI_chars); } It seems perhaps we need to fix that first! John > for inst_type in inst_list: > logger.info("Verifying '%s' records", inst_type) > > From jferlan at redhat.com Wed Aug 7 00:09:07 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 06 Aug 2013 20:09:07 -0400 Subject: [Libvirt-cim] [PATCH 1/2] cimtest: Add default network existence check to 28_definesystem_with_vsi_profile.py In-Reply-To: <1375322922-22761-2-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375322922-22761-1-git-send-email-gesaint@linux.vnet.ibm.com> <1375322922-22761-2-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <52019023.6090109@redhat.com> On 07/31/2013 10:08 PM, Xu Wang wrote: > From: Xu Wang > > The default network card name is 'eth0' or 'em1'. But if the network > card name doesn't contain those values, error would occur. So this patch > will check if the default network card name exists in the network > card name list. If not, the network card name would changed into > the first one in the network card name list except lo. > > Signed-off-by: Xu Wang Although the test fails in general for me based on my system configuration, I did verify that by using either "eth1" or "em1" as the initial value, that the changes here work, so ACK John > --- > .../28_definesystem_with_vsi_profile.py | 9 +++++++++ > 1 files changed, 9 insertions(+), 0 deletions(-) > > diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py > index 2b108f9..a901ae7 100644 > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py > @@ -33,6 +33,7 @@ > # > > import sys > +import os > from CimTest.Globals import logger > from CimTest.ReturnCodes import FAIL, PASS, SKIP, XFAIL_RC, XFAIL > from VirtLib import utils > @@ -188,6 +189,14 @@ def main(): > if rc == 0: > vsi_defaults['SourceDevice'] = "em1" > > + # The default device name may not named 'eth1' or 'em1' so this case would > + # return FAIL. The following code will check if default device exists in > + # the network card list and if not, source_dev will be changed into the 1st > + # network card in the list. > + net_info = os.popen('ip addr').read() > + if net_info.find(vsi_defaults['SourceDevice']) == -1: > + vsi_defaults['SourceDevice'] = net_info.split(': ')[3] > + > nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData') > status = FAIL > cxml = None > From gesaint at linux.vnet.ibm.com Wed Aug 7 08:37:10 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Wed, 7 Aug 2013 16:37:10 +0800 Subject: [Libvirt-cim] [PATCH V2 0/3] cimtest: Add default network device availability check Message-ID: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> The default network device is a constant value. But if it doesn't exist in the system some failure would occur. Hence these patches add checking existence of them. If default network card name exists in the network info list, it will be kept. If not, the value of it will be changed into the 1st available one in the network info list. Xu Wang (3): cimtest: Add default network card name existence check to 27_definesystem_macvtap_dev.py cimtest: Add default network existence check to 28_definesystem_with_vsi_profile.py cimtest: Add default network existence check to 06_parent_net_pool.py .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 25 +++++++++++++++++-- .../27_definesystem_macvtap_dev.py | 16 ++++++++++++ .../28_definesystem_with_vsi_profile.py | 17 +++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) From gesaint at linux.vnet.ibm.com Wed Aug 7 08:37:13 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Wed, 7 Aug 2013 16:37:13 +0800 Subject: [Libvirt-cim] [PATCH V2 3/3] cimtest: Add default network existence check to 06_parent_net_pool.py In-Reply-To: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1375864633-16518-4-git-send-email-gesaint@linux.vnet.ibm.com> The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list. Signed-off-by: Xu Wang --- .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 25 +++++++++++++++++-- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py index 2c1f285..d8b82ca 100644 --- a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py +++ b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py @@ -39,7 +39,8 @@ # -Netmask="255.255.255.0" # -IPRangeStart="192.168.122.2" # -IPRangeEnd="192.168.122.254" -# -ForwardDevice= [ verified for 'None' and "eth0" ] +# -ForwardDevice= [ verified for 'None' and forward device name \ +# (default is 'eth0' if available) ] # -ForwardMode=0 [ verified for 1,2 as well ] # # @@ -47,6 +48,7 @@ # Date : 18-05-2009 import sys +import os from sets import Set from CimTest.Globals import logger from XenKvmLib.const import do_main @@ -67,6 +69,23 @@ def main(): options = main.options virt = options.virt server = options.ip + net_dev = 'eth0' + + # The default device name may not named 'eth0', so this case would + # return FAIL. The following code will check if default device exists in + # the network card list and if not, source_dev will be changed into the 1st + # network card in the list. + f = open("/proc/net/dev") + lines = f.readlines() + f.close() + if str(lines).find(net_dev) <> -1: + """ + net_dev exists in the network info list and keep it. + """ + else: + line = lines[2] + con = line.split(":") + net_dev = con[0].strip(" ") status, netpool_rasd = get_pool_rasds(server, virt, filter_default=False) if status != PASS: @@ -80,8 +99,8 @@ def main(): 'IPRangeStart' : "192.168.122.2", 'IPRangeEnd' : "192.168.122.254" } - exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), - ('None', 2L), ('eth0', 2L)] + exp_mode_device = [('None', 0L), ('None', 1L), (net_dev, 1L), + ('None', 2L), (net_dev, 2L)] for inst_type in inst_list: logger.info("Verifying '%s' records", inst_type) -- 1.7.1 From gesaint at linux.vnet.ibm.com Wed Aug 7 08:37:11 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Wed, 7 Aug 2013 16:37:11 +0800 Subject: [Libvirt-cim] [PATCH V2 1/3] cimtest: Add default network card name existence check to 27_definesystem_macvtap_dev.py In-Reply-To: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1375864633-16518-2-git-send-email-gesaint@linux.vnet.ibm.com> Default network card name was set as 'eth1' or 'em1'. But when os has no network card named like that, FAIL would occured. This patch added check if default name exists in the network card list and if not, change the default value into the 1st one in the list. Signed-off-by: Xu Wang --- .../27_definesystem_macvtap_dev.py | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py index 36bf52f..bc8c100 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py @@ -132,6 +132,22 @@ def main(): else: source_dev = "eth1" + # The default device name may not named 'eth1' or 'em1' so this case would + # return FAIL. The following code will check if default device exists in + # the network card list and if not, source_dev will be changed into the 1st + # network card in the list. + f = open("/proc/net/dev") + lines = f.readlines() + f.close() + if str(lines).find(source_dev) <> -1: + """ + source_dev exists in the network info list and keep it. + """ + else: + line = lines[2] + con = line.split(":") + source_dev = con[0].strip(" ") + guest_defined = False try: -- 1.7.1 From gesaint at linux.vnet.ibm.com Wed Aug 7 08:37:12 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Wed, 7 Aug 2013 16:37:12 +0800 Subject: [Libvirt-cim] [PATCH V2 2/3] cimtest: Add default network existence check to 28_definesystem_with_vsi_profile.py In-Reply-To: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1375864633-16518-3-git-send-email-gesaint@linux.vnet.ibm.com> The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list. Signed-off-by: Xu Wang --- .../28_definesystem_with_vsi_profile.py | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py index 2b108f9..b7f8a5e 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py @@ -188,6 +188,23 @@ def main(): if rc == 0: vsi_defaults['SourceDevice'] = "em1" + # The default device name may not named 'eth1' or 'em1' so this case would + # return FAIL. The following code will check if default device exists in + # the network card list and if not, source_dev will be changed into the 1st + # network card in the list. + f = open("/proc/net/dev") + lines = f.readlines() + f.close() + if str(lines).find(vsi_defaults['SourceDevice']) <> -1: + """ + Default net dev exists in the network info list and keep it. + """ + else: + line = lines[2] + con = line.split(":") + vsi_defaults['SourceDevice'] = con[0].strip(" ") + + nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData') status = FAIL cxml = None -- 1.7.1 From gesaint at linux.vnet.ibm.com Wed Aug 7 08:46:39 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Wed, 7 Aug 2013 16:46:39 +0800 Subject: [Libvirt-cim] [PATCH V2] Add default network card existence checking Message-ID: <1375865199-16785-1-git-send-email-gesaint@linux.vnet.ibm.com> The default network card (used as forward device in network pool) name was set as "eth0" in Virt_SettingDefineCapabilities.c. This patch added check if there is such a network card exists in the network info list. If it exists, use it. If not, the default network card would be changed into the first one in the network devices list. Signed-off-by: Xu Wang --- libxkutil/misc_util.c | 39 +++++++++++++++++++++++++++++++++ libxkutil/misc_util.h | 2 +- src/Virt_SettingsDefineCapabilities.c | 6 ++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 9e7e0d5..7541aa3 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include "cmpidt.h" #include "cmpift.h" @@ -900,6 +902,43 @@ int virt_set_status(const CMPIBroker *broker, return ret; } +char *get_avail_net(const char *def_name) +{ + int fd; + int interfaceNum = 0; + struct ifreq buf[16]; + struct ifconf ifc; + char *avail_name = NULL; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + CU_DEBUG("socket() failed."); + goto out; + } + + ifc.ifc_len = sizeof(buf); + ifc.ifc_buf = (caddr_t)buf; + if (!ioctl(fd, SIOCGIFCONF, (char *)&ifc)) { + interfaceNum = ifc.ifc_len / sizeof(struct ifreq); + CU_DEBUG("interface num = %d", interfaceNum); + while (interfaceNum-- > 0) { + CU_DEBUG("network device name: %s", buf[interfaceNum].ifr_name); + if (!strcmp(def_name, buf[interfaceNum].ifr_name)) { + avail_name = strdup(buf[interfaceNum].ifr_name); + goto out; + } + } + + avail_name = strdup(buf[0].ifr_name); + } else { + CU_DEBUG("ioctl: %s [%s:%d]\n", strerror(errno), __FILE__, __LINE__); + goto out; + } + +out: + close(fd); + return avail_name; +} + /* * Local Variables: diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h index fd4f191..9489a18 100644 --- a/libxkutil/misc_util.h +++ b/libxkutil/misc_util.h @@ -157,7 +157,7 @@ const char *get_mig_ssh_tmp_key(void); bool get_disable_kvm(void); const char *get_lldptool_query_options(void); const char *get_vsi_support_key_string(void); - +char *get_avail_net(const char *def_name); /* * Local Variables: * mode: C diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c index 78c128c..817980c 100644 --- a/src/Virt_SettingsDefineCapabilities.c +++ b/src/Virt_SettingsDefineCapabilities.c @@ -777,6 +777,7 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, int dev_count; int i; char *tmp_str = NULL; + char *forward_device = NULL; /* Isolated network pools don't have a forward device */ if (pool_type == NETPOOL_FORWARD_NONE) @@ -836,14 +837,17 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, (CMPIValue *)&pool_type, CMPI_uint16); if (i == 1) { + forward_device = get_avail_net("eth0"); + CMSetProperty(inst, "ForwardDevice", - (CMPIValue *)"eth0", CMPI_chars); + (CMPIValue *)forward_device, CMPI_chars); } inst_list_add(list, inst); } out: + free(forward_device); return s; } -- 1.7.1 From mprivozn at redhat.com Thu Aug 8 09:51:33 2013 From: mprivozn at redhat.com (Michal Privoznik) Date: Thu, 8 Aug 2013 11:51:33 +0200 Subject: [Libvirt-cim] [PATCH] get_dominfo: Use VIR_DOMAIN_XML_SECURE more wisely Message-ID: <7e164fbdac05e955fe21c5bacc4aeee171821fd5.1375955494.git.mprivozn@redhat.com> Currently, even if we are connected RO to the libvirtd, we try to dump domain XML with secure information (VIR_DOMAIN_XML_SECURE flag). This is, however, forbidden in libvirt. With RO connection, we should not use the SECURE flag at all. --- libxkutil/device_parsing.c | 9 +++++++-- libxkutil/misc_util.c | 2 +- libxkutil/misc_util.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 7900e06..ffdf682 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -31,6 +31,7 @@ #include #include "device_parsing.h" +#include "misc_util.h" #include "xmlgen.h" #include "../src/svpc_types.h" @@ -1283,8 +1284,12 @@ int get_dominfo(virDomainPtr dom, struct domain **dominfo) char *xml; int ret = 0; int start; - xml = virDomainGetXMLDesc(dom, - VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE); + int flags = VIR_DOMAIN_XML_INACTIVE; + + if (!is_read_only()) + flags |= VIR_DOMAIN_XML_SECURE; + + xml = virDomainGetXMLDesc(dom, flags); if (xml == NULL) { CU_DEBUG("Failed to get dom xml with libvirt API."); diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 9e7e0d5..2164dd0 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -219,7 +219,7 @@ static int libvirt_cim_config_get(LibvirtcimConfigProperty *prop) } #endif -static int is_read_only(void) +int is_read_only(void) { static LibvirtcimConfigProperty prop = { "readonly", CONFIG_BOOL, {0}, 0}; diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h index fd4f191..056c327 100644 --- a/libxkutil/misc_util.h +++ b/libxkutil/misc_util.h @@ -153,6 +153,7 @@ int virt_set_status(const CMPIBroker *broker, #define REF2STR(r) CMGetCharPtr(CMObjectPathToString(r, NULL)) /* get libvirt-cim config */ +int is_read_only(void); const char *get_mig_ssh_tmp_key(void); bool get_disable_kvm(void); const char *get_lldptool_query_options(void); -- 1.8.1.5 From mprivozn at redhat.com Thu Aug 8 09:51:34 2013 From: mprivozn at redhat.com (Michal Privoznik) Date: Thu, 8 Aug 2013 11:51:34 +0200 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Don't install open-pegasus' specific providers In-Reply-To: <7e164fbdac05e955fe21c5bacc4aeee171821fd5.1375955494.git.mprivozn@redhat.com> References: <7e164fbdac05e955fe21c5bacc4aeee171821fd5.1375955494.git.mprivozn@redhat.com> Message-ID: <19ffef8e60a3cb90b41043ebda3063355896b6a7.1375955494.git.mprivozn@redhat.com> https://bugzilla.redhat.com/show_bug.cgi?id=859122 libvirt-cim installs open-pegasus' specific providers in sblim-sfcb repository staging directory and causing problem when creating sfcb repository. --- libvirt-cim.spec.in | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index 7b6221e..a027246 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -133,9 +133,6 @@ then -n root/interop \ -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true %{_datadir}/%{name}/provider-register.sh -t sfcb \ - -n root/PG_InterOp \ - -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true -%{_datadir}/%{name}/provider-register.sh -t sfcb \ -n root/cimv2\ -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true fi @@ -165,9 +162,6 @@ then -n root/interop \ -r %{INTEROP_REG} -m %{INTEROP_MOF} >/dev/null 2>&1 || true %{_datadir}/%{name}/provider-register.sh -d -t sfcb \ - -n root/PG_InterOp \ - -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true -%{_datadir}/%{name}/provider-register.sh -d -t sfcb \ -n root/cimv2 \ -r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true fi -- 1.8.1.5 From mihajlov at linux.vnet.ibm.com Thu Aug 8 13:27:53 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 8 Aug 2013 15:27:53 +0200 Subject: [Libvirt-cim] [PATCH] libcmpiutil: Fix endianness issues in embedded object parsing Message-ID: <1375968473-12020-1-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm The auxiliary functions _set_int_prop/parse_int_property only worked on little-endian archs as they performed an incorrect reinterpretation of 64bit integers. Fixed by using the proper CMPIValue union fields. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski --- eo_parser.c | 35 ++++++++++++++++++++++------------- eo_parser_xml.c | 49 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/eo_parser.c b/eo_parser.c index 36106fd..4c5b0ee 100644 --- a/eo_parser.c +++ b/eo_parser.c @@ -113,31 +113,40 @@ static int _set_int_prop(CMPISint64 value, CMPIInstance *inst) { CMPIStatus s; - uint64_t unsigned_val = 0; - int64_t signed_val = 0; + CMPIValue val; - switch(type) { + switch (type) { case CMPI_uint64: + val.uint64 = (uint64_t) value; + break; case CMPI_uint32: + val.uint32 = (uint32_t) value; + break; case CMPI_uint16: + val.uint16 = (uint16_t) value; + break; case CMPI_uint8: - unsigned_val = (uint64_t) value; - s = CMSetProperty(inst, - prop, - (CMPIValue *) &(unsigned_val), - type); + val.uint8 = (uint8_t) value; break; case CMPI_sint64: + val.sint64 = (int64_t) value; + break; case CMPI_sint32: + val.sint32 = (int32_t) value; + break; case CMPI_sint16: + val.sint16 = (int16_t) value; + break; case CMPI_sint8: + val.sint8 = (int8_t) value; + break; default: - signed_val = (int64_t) value; - s = CMSetProperty(inst, - prop, - (CMPIValue *) &(signed_val), - type); + return 0; } + s = CMSetProperty(inst, + prop, + &val, + type); if (s.rc == CMPI_RC_OK) return 1; diff --git a/eo_parser_xml.c b/eo_parser_xml.c index c8b28cc..234b04b 100644 --- a/eo_parser_xml.c +++ b/eo_parser_xml.c @@ -90,11 +90,48 @@ static CMPIType parse_int_property(const char *string, if (sign) { int64_t _val; ret = sscanf(string, "%" SCNi64, &_val); - val->sint64 = _val; + switch (size) { + case 8: + t = CMPI_sint8; + val->sint8 = (int8_t) _val; + break; + case 16: + t = CMPI_sint16; + val->sint16 = (int16_t) _val; + break; + case 32: + t = CMPI_sint32; + val->sint32 = (int32_t) _val; + break; + default: + case 64: + t = CMPI_sint64; + val->sint64 = (int64_t) _val; + break; + }; } else { uint64_t _val; ret = sscanf(string, "%" SCNu64, &_val); - val->uint64 = _val; + switch (size) { + case 8: + t = CMPI_uint8; + val->uint8 = (uint8_t) _val; + break; + case 16: + t = CMPI_uint16; + val->uint16 = (uint16_t) _val; + break; + case 32: + t = CMPI_uint32; + val->uint32 = (uint32_t) _val; + break; + default: + case 64: + t = CMPI_uint64; + val->uint64 = (uint64_t) _val; + break; + + }; } if (ret != 1) { @@ -102,14 +139,6 @@ static CMPIType parse_int_property(const char *string, return CMPI_null; } - switch (size) { - case 8: t = sign ? CMPI_sint8 : CMPI_uint8; break; - case 16: t = sign ? CMPI_sint16 : CMPI_uint16; break; - case 32: t = sign ? CMPI_sint32 : CMPI_uint32; break; - default: - case 64: t = sign ? CMPI_sint64 : CMPI_uint64; break; - }; - return t; } -- 1.7.9.5 From jferlan at redhat.com Thu Aug 8 19:30:17 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 15:30:17 -0400 Subject: [Libvirt-cim] [PATCH V2] Add default network card existence checking In-Reply-To: <1375865199-16785-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375865199-16785-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5203F1C9.70303@redhat.com> On 08/07/2013 04:46 AM, Xu Wang wrote: > The default network card (used as forward device in network pool) name > was set as "eth0" in Virt_SettingDefineCapabilities.c. This patch added > check if there is such a network card exists in the network info list. > If it exists, use it. If not, the default network card would be changed > into the first one in the network devices list. > > Signed-off-by: Xu Wang Something is not quite right - I got the following result when using this code and the RASD test -------------------------------------------------------------------- RASD - 06_parent_net_pool.py: FAIL ERROR - Exception details: Mismatching Mode and device values, Got [('None', 0L), ('None', 1L), ('tun0', 1L), ('None', 2L), ('tun0', 2L)], Expected [('None', 0L), ('None', 1L), ('lo', 1L), ('None', 2L), ('lo', 2L)] -------------------------------------------------------------------- I seem to have had some other failures afterwards which caused libvirtd to crash, but that could be because I'm running with top of tree and other changes... If I cut out your code and run it in it's own program passing "eth0" as a parameter here's what I get (although em1 is what I'd be expecting to return): interface num = 4 network device name: tun0 network device name: virbr0 network device name: em1 network device name: lo forward_device = lo I have Fedora 19.. and here's some ip addr results: 1: lo: mtu 65536 qdisc noqueue state UNKNOWN 2: em1: mtu 1500 qdisc pfifo_fast state UP qlen 1000 3: wlp3s0: mtu 1500 qdisc noop state DOWN qlen 1000 4: virbr0: mtu 1500 qdisc noqueue state UP 5: vnet0: mtu 1500 qdisc pfifo_fast master virbr0 state UNKNOWN qlen 500 6: tun0: mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100 8: vnet1: mtu 1500 qdisc pfifo_fast master virbr0 state UNKNOWN qlen 500 and ifconfig: em1: flags=4163 mtu 1500 lo: flags=73 mtu 65536 tun0: flags=4305 mtu 1500 virbr0: flags=4163 mtu 1500 vnet0: flags=4163 mtu 1500 vnet1: flags=4163 mtu 1500 Specific comments below > --- > libxkutil/misc_util.c | 39 +++++++++++++++++++++++++++++++++ > libxkutil/misc_util.h | 2 +- > src/Virt_SettingsDefineCapabilities.c | 6 ++++- > 3 files changed, 45 insertions(+), 2 deletions(-) > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > index 9e7e0d5..7541aa3 100644 > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -33,6 +33,8 @@ > #include > #include > #include > +#include > +#include > > #include "cmpidt.h" > #include "cmpift.h" > @@ -900,6 +902,43 @@ int virt_set_status(const CMPIBroker *broker, > return ret; > } > > +char *get_avail_net(const char *def_name) > +{ > + int fd; > + int interfaceNum = 0; > + struct ifreq buf[16]; > + struct ifconf ifc; > + char *avail_name = NULL; > + ^ 'git am' complains about trailing whitespace > + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { > + CU_DEBUG("socket() failed."); > + goto out; Need to add extra space before each line > + } > + ^ 'git am' complains about trailing whitespace > + ifc.ifc_len = sizeof(buf); > + ifc.ifc_buf = (caddr_t)buf; If you're going to go this route SIOCGIFCOUNT will get you the interface count so you don't have use a constant 16 value which could be too limiting. > + if (!ioctl(fd, SIOCGIFCONF, (char *)&ifc)) { > + interfaceNum = ifc.ifc_len / sizeof(struct ifreq); > + CU_DEBUG("interface num = %d", interfaceNum); Unfortunately you know nothing "about" the interface - just that it exists and that's your sole criteria for selecting. If you don't find the one that's passed in you select the last one in the list - which happens to be loopback (lo) which certainly isn't what you want. You can look at libvirt source code src/util/virnetdev.c for some sample processing - get the names, get their flags, get other state/date info about them. I think the method I had asked for before was to use bind to INADDR_ANY and socket/bind. It's been a while since I've had to do this so I'm not sure of the best mechanism to use to solve the problem to find a network interface card that can/should be used for this. One would think there'd be an easier way to get what is wanted here! > + while (interfaceNum-- > 0) { > + CU_DEBUG("network device name: %s", buf[interfaceNum].ifr_name); > + if (!strcmp(def_name, buf[interfaceNum].ifr_name)) { > + avail_name = strdup(buf[interfaceNum].ifr_name); > + goto out; > + } > + } > + > + avail_name = strdup(buf[0].ifr_name); > + } else { > + CU_DEBUG("ioctl: %s [%s:%d]\n", strerror(errno), __FILE__, __LINE__); > + goto out; Need to remove extra space before each of the lines above > + } > + ^ 'git am' complains about trailing whitespace > +out: > + close(fd); if (fd >= 0) close(fd); > + return avail_name; > +} > + > > /* > * Local Variables: > diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h > index fd4f191..9489a18 100644 > --- a/libxkutil/misc_util.h > +++ b/libxkutil/misc_util.h > @@ -157,7 +157,7 @@ const char *get_mig_ssh_tmp_key(void); > bool get_disable_kvm(void); > const char *get_lldptool_query_options(void); > const char *get_vsi_support_key_string(void); > - > +char *get_avail_net(const char *def_name); > /* > * Local Variables: > * mode: C > diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c > index 78c128c..817980c 100644 > --- a/src/Virt_SettingsDefineCapabilities.c > +++ b/src/Virt_SettingsDefineCapabilities.c > @@ -777,6 +777,7 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, > int dev_count; > int i; > char *tmp_str = NULL; > + char *forward_device = NULL; > > /* Isolated network pools don't have a forward device */ > if (pool_type == NETPOOL_FORWARD_NONE) > @@ -836,14 +837,17 @@ static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, > (CMPIValue *)&pool_type, CMPI_uint16); > > if (i == 1) { > + forward_device = get_avail_net("eth0"); > + > CMSetProperty(inst, "ForwardDevice", > - (CMPIValue *)"eth0", CMPI_chars); > + (CMPIValue *)forward_device, CMPI_chars); > } > > inst_list_add(list, inst); > } > > out: > + free(forward_device); > return s; > } > > From jferlan at redhat.com Thu Aug 8 19:38:52 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 15:38:52 -0400 Subject: [Libvirt-cim] [PATCH V2 1/3] cimtest: Add default network card name existence check to 27_definesystem_macvtap_dev.py In-Reply-To: <1375864633-16518-2-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> <1375864633-16518-2-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5203F3CC.3060402@redhat.com> On 08/07/2013 04:37 AM, Xu Wang wrote: > Default network card name was set as 'eth1' or 'em1'. But when os has no network card named like that, FAIL > would occured. This patch added check if default name exists in the network card list and if not, change > the default value into the 1st one in the list. > I believe you neglected git pull --refresh before sending this patch as it doesn't apply to the top of the .git tree since DV pushed your previous patch... > Signed-off-by: Xu Wang > --- > .../27_definesystem_macvtap_dev.py | 16 ++++++++++++++++ > 1 files changed, 16 insertions(+), 0 deletions(-) > > diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py > index 36bf52f..bc8c100 100644 > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py > @@ -132,6 +132,22 @@ def main(): > else: > source_dev = "eth1" > > + # The default device name may not named 'eth1' or 'em1' so this case would > + # return FAIL. The following code will check if default device exists in > + # the network card list and if not, source_dev will be changed into the 1st > + # network card in the list. > + f = open("/proc/net/dev") > + lines = f.readlines() > + f.close() > + if str(lines).find(source_dev) <> -1: > + """ > + source_dev exists in the network info list and keep it. > + """ > + else: > + line = lines[2] why pick 2? other than 1 being "lo"? what makes us sure that this is correct and usable? > + con = line.split(":") > + source_dev = con[0].strip(" ") > + There should be a more common way to do this rather than cut-n-paste into 3 modules... John > guest_defined = False > > try: > From jferlan at redhat.com Thu Aug 8 19:39:51 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 15:39:51 -0400 Subject: [Libvirt-cim] [PATCH V2 3/3] cimtest: Add default network existence check to 06_parent_net_pool.py In-Reply-To: <1375864633-16518-4-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> <1375864633-16518-4-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5203F407.7030205@redhat.com> On 08/07/2013 04:37 AM, Xu Wang wrote: > The default network card name is 'eth0' or 'em1'. But if the network > card name doesn't contain those values, error would occur. So this patch > will check if the default network card name exists in the network > card name list. If not, the network card name would changed into > the first one in the network card name list. > > Signed-off-by: Xu Wang > --- > .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 25 +++++++++++++++++-- > 1 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py > index 2c1f285..d8b82ca 100644 > --- a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py > +++ b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py > @@ -39,7 +39,8 @@ > # -Netmask="255.255.255.0" > # -IPRangeStart="192.168.122.2" > # -IPRangeEnd="192.168.122.254" > -# -ForwardDevice= [ verified for 'None' and "eth0" ] > +# -ForwardDevice= [ verified for 'None' and forward device name \ > +# (default is 'eth0' if available) ] > # -ForwardMode=0 [ verified for 1,2 as well ] > # > # > @@ -47,6 +48,7 @@ > # Date : 18-05-2009 > > import sys > +import os > from sets import Set > from CimTest.Globals import logger > from XenKvmLib.const import do_main > @@ -67,6 +69,23 @@ def main(): > options = main.options > virt = options.virt > server = options.ip > + net_dev = 'eth0' > + > + # The default device name may not named 'eth0', so this case would > + # return FAIL. The following code will check if default device exists in > + # the network card list and if not, source_dev will be changed into the 1st > + # network card in the list. > + f = open("/proc/net/dev") > + lines = f.readlines() > + f.close() > + if str(lines).find(net_dev) <> -1: > + """ > + net_dev exists in the network info list and keep it. > + """ > + else: > + line = lines[2] > + con = line.split(":") > + net_dev = con[0].strip(" ") > This is a very different algorithm than how you get the valid network interfaces in libvirt-cim - hence you get different results. Like 1/3 - there needs to be a common interface which this can reference > status, netpool_rasd = get_pool_rasds(server, virt, filter_default=False) > if status != PASS: > @@ -80,8 +99,8 @@ def main(): > 'IPRangeStart' : "192.168.122.2", > 'IPRangeEnd' : "192.168.122.254" > } > - exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), > - ('None', 2L), ('eth0', 2L)] > + exp_mode_device = [('None', 0L), ('None', 1L), (net_dev, 1L), ^ Again, 'git am' reports trailing whitespace on the above line - there's an extra space at the end. John > + ('None', 2L), (net_dev, 2L)] > for inst_type in inst_list: > logger.info("Verifying '%s' records", inst_type) > > From jferlan at redhat.com Thu Aug 8 19:40:53 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 15:40:53 -0400 Subject: [Libvirt-cim] [PATCH V2 2/3] cimtest: Add default network existence check to 28_definesystem_with_vsi_profile.py In-Reply-To: <1375864633-16518-3-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375864633-16518-1-git-send-email-gesaint@linux.vnet.ibm.com> <1375864633-16518-3-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5203F445.3040508@redhat.com> On 08/07/2013 04:37 AM, Xu Wang wrote: > The default network card name is 'eth0' or 'em1'. But if the network > card name doesn't contain those values, error would occur. So this patch > will check if the default network card name exists in the network > card name list. If not, the network card name would changed into > the first one in the network card name list. > > Signed-off-by: Xu Wang > --- > .../28_definesystem_with_vsi_profile.py | 17 +++++++++++++++++ > 1 files changed, 17 insertions(+), 0 deletions(-) > > diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py > index 2b108f9..b7f8a5e 100644 > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py > @@ -188,6 +188,23 @@ def main(): > if rc == 0: > vsi_defaults['SourceDevice'] = "em1" > > + # The default device name may not named 'eth1' or 'em1' so this case would > + # return FAIL. The following code will check if default device exists in > + # the network card list and if not, source_dev will be changed into the 1st > + # network card in the list. > + f = open("/proc/net/dev") > + lines = f.readlines() > + f.close() > + if str(lines).find(vsi_defaults['SourceDevice']) <> -1: > + """ > + Default net dev exists in the network info list and keep it. > + """ > + else: > + line = lines[2] > + con = line.split(":") > + vsi_defaults['SourceDevice'] = con[0].strip(" ") > + > + Like 1/3 - needs to be common routine. Again you're getting different and unexpected results. John > nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData') > status = FAIL > cxml = None > From jferlan at redhat.com Thu Aug 8 20:01:33 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 16:01:33 -0400 Subject: [Libvirt-cim] [PATCH] fix xmt-makefv.sh die() output In-Reply-To: <1375516888-12593-1-git-send-email-jmiao@redhat.com> References: <1375516888-12593-1-git-send-email-jmiao@redhat.com> Message-ID: <5203F91D.7090602@redhat.com> On 08/03/2013 04:01 AM, Jincheng Miao wrote: > If xmt-makefv.sh failed, it will prompt FAILED: . But the reason part > is blank. It is because die() in xmt-makefv.sh use $i to show the reason. That > should be $1 rather than $i. > ACK John From jferlan at redhat.com Thu Aug 8 20:02:52 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 16:02:52 -0400 Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <1375546457-2946-1-git-send-email-jmiao@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> Message-ID: <5203F96C.8050206@redhat.com> On 08/03/2013 12:14 PM, Jincheng Miao wrote: > Parted-3.1 remove mkpartfs capability. When generating guest images, it should > use external tools (like mke2fs) to create filesystem. > > Signed-off-by: Jincheng Miao I'm not the expert here - how would I know whether this works? I read the README, ran make but it didn't succeed: # make chmod +x xmt-convert.sh (cd xm-test && sh ../xmt-convert.sh `basename xm-test/initrd-1.1-i386.img`) 1856 blocks if uname -r | grep -q xen; then \ cp /boot/vmlinuz-`uname -r` /var/lib/libvirt/images/default-xen-kernel; \ fi chmod +x xmt-makefv.sh ./xmt-makefv.sh xm-test/xm-test.gz xm-test/xmt_disk.img Warning: The resulting partition is not properly aligned for best performance. FAILED: No kver 0-rescue-9481a187403f46b38d535cf9ffa1cc20 make: *** [xm-test/xmt_disk.img] Error 1 John > --- > suites/libvirt-cim/images/xmt-makefv.sh | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/suites/libvirt-cim/images/xmt-makefv.sh b/suites/libvirt-cim/images/xmt-makefv.sh > index 1cf6a0f..85a340c 100755 > --- a/suites/libvirt-cim/images/xmt-makefv.sh > +++ b/suites/libvirt-cim/images/xmt-makefv.sh > @@ -51,7 +51,7 @@ partition() { > local file=$1 > > $PARTED $file mklabel msdos > - $PARTED $file mkpartfs primary ext2 0 $(($SIZE - 1)) > + $PARTED $file mkpart primary ext2 0 $(($SIZE - 1)) > } > > mount_partition() { > @@ -62,7 +62,10 @@ mount_partition() { > > losetup /dev/$loopdev $file || die "Failed to losetup $file" > kpartx -a /dev/$loopdev || die "Failed to kpartx $loopdev" > + sleep 2 > + mke2fs -t ext2 /dev/mapper/${loopdev}p1 >/dev/null 2>&1 || die "Failed to mkfs ${loopdev}p1" > tune2fs -j /dev/mapper/${loopdev}p1 >/dev/null 2>&1|| die "Failed to add journal" > + sleep 2 > mount /dev/mapper/${loopdev}p1 $TMPMOUNT || die "Failed to mount ${loopdev}p1" > > echo $loopdev > From jferlan at redhat.com Thu Aug 8 22:07:07 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 18:07:07 -0400 Subject: [Libvirt-cim] [PATCH] get_dominfo: Use VIR_DOMAIN_XML_SECURE more wisely In-Reply-To: <7e164fbdac05e955fe21c5bacc4aeee171821fd5.1375955494.git.mprivozn@redhat.com> References: <7e164fbdac05e955fe21c5bacc4aeee171821fd5.1375955494.git.mprivozn@redhat.com> Message-ID: <5204168B.1090800@redhat.com> On 08/08/2013 05:51 AM, Michal Privoznik wrote: > Currently, even if we are connected RO to the libvirtd, we try to dump > domain XML with secure information (VIR_DOMAIN_XML_SECURE flag). This > is, however, forbidden in libvirt. With RO connection, we should not use > the SECURE flag at all. > --- > libxkutil/device_parsing.c | 9 +++++++-- > libxkutil/misc_util.c | 2 +- > libxkutil/misc_util.h | 1 + > 3 files changed, 9 insertions(+), 3 deletions(-) > ACK Although my cimtest is failing as a result of another bug added to the top of the libvirt git tree. I have chased that bug a bit and notified the For anyone pulling up a top of tree, don't run: VirtualSystemManagementService and 30_dynamic_disk_mod.py John From jferlan at redhat.com Thu Aug 8 22:07:55 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 18:07:55 -0400 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Don't install open-pegasus' specific providers In-Reply-To: <19ffef8e60a3cb90b41043ebda3063355896b6a7.1375955494.git.mprivozn@redhat.com> References: <7e164fbdac05e955fe21c5bacc4aeee171821fd5.1375955494.git.mprivozn@redhat.com> <19ffef8e60a3cb90b41043ebda3063355896b6a7.1375955494.git.mprivozn@redhat.com> Message-ID: <520416BB.5080902@redhat.com> On 08/08/2013 05:51 AM, Michal Privoznik wrote: > https://bugzilla.redhat.com/show_bug.cgi?id=859122 > > libvirt-cim installs open-pegasus' specific providers in sblim-sfcb > repository staging directory and causing problem when creating sfcb > repository. > --- > libvirt-cim.spec.in | 6 ------ > 1 file changed, 6 deletions(-) > ACK John From jferlan at redhat.com Thu Aug 8 22:16:39 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 8 Aug 2013 18:16:39 -0400 Subject: [Libvirt-cim] [PATCH 0/3] Address 'cimtest' issues Message-ID: <1376000202-20533-1-git-send-email-jferlan@redhat.com> These patches resolve some issues with test logging and there's one test fix that I've had just hanging around that I figure I'd put out there since there was some activity. John Ferlan (3): Allow adding bridged network for running domain Remove extranous or unnecessary parameter from error messages Ensure get_provider_version() returns strings as expected .../cimtest/Profile/03_rprofile_gi_errs.py | 2 +- suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py | 2 +- .../cimtest/ResourcePool/02_rp_gi_errors.py | 2 +- .../22_addmulti_brg_interface.py | 9 +++++++-- suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 23 +++++++++++++++++----- 6 files changed, 29 insertions(+), 11 deletions(-) -- 1.8.3.1 From jferlan at redhat.com Thu Aug 8 22:16:42 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 8 Aug 2013 18:16:42 -0400 Subject: [Libvirt-cim] [PATCH 3/3] Ensure get_provider_version() returns strings as expected In-Reply-To: <1376000202-20533-1-git-send-email-jferlan@redhat.com> References: <1376000202-20533-1-git-send-email-jferlan@redhat.com> Message-ID: <1376000202-20533-4-git-send-email-jferlan@redhat.com> The reporting.py had a failure: Traceback (most recent call last): File "main.py", line 326, in ret = main(options, args) File "main.py", line 312, in main msg_body, heading = gen_report(options.virt, options.ip, testsuite.log_file) File "./lib/XenKvmLib/reporting.py", line 168, in gen_report sys_env, distro = get_env_data(ip, virt) File "./lib/XenKvmLib/reporting.py", line 109, in get_env_data return env + lc_ver + cimtest_ver, distro UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 31: ordinal not in range(128) --- suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py b/suites/libvirt-cim/lib/XenKvmLib/const.py index 6701d36..d17fef3 100755 --- a/suites/libvirt-cim/lib/XenKvmLib/const.py +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py @@ -180,6 +180,6 @@ def get_provider_version(virt, ip): if revision.isdigit(): revision = int(revision) - return revision, changeset + return str(revision), str(changeset) -- 1.8.3.1 From jferlan at redhat.com Thu Aug 8 22:16:41 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 8 Aug 2013 18:16:41 -0400 Subject: [Libvirt-cim] [PATCH 2/3] Remove extranous or unnecessary parameter from error messages In-Reply-To: <1376000202-20533-1-git-send-email-jferlan@redhat.com> References: <1376000202-20533-1-git-send-email-jferlan@redhat.com> Message-ID: <1376000202-20533-3-git-send-email-jferlan@redhat.com> Testing on a system failed with: Profile - 03_rprofile_gi_errs.py: FAIL ERROR - Unexpected errno 5, desc Class not found ERROR - Expected No such instance 6 ERROR - NameError : global name 'tc' is not defined Traceback (most recent call last): File "/root/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "03_rprofile_gi_errs.py", line 85, in main logger.error("------ FAILED: %s %s ------", cn, tc) NameError: global name 'tc' is not defined ERROR - None Turns out the profile test doesn't define/use tc. Found 2 other such occurrances and fixed them as well. --- suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py | 2 +- suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py | 2 +- suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py b/suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py index 4633cce..fa2a634 100644 --- a/suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py +++ b/suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py @@ -82,7 +82,7 @@ def main(): logger.error("Expected %s %s", exp_desc, exp_rc) if status != PASS: - logger.error("------ FAILED: %s %s ------", cn, tc) + logger.error("------ FAILED: InstanceID Key Value. ------") Globals.CIM_NS = prev_namespace return status diff --git a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py index 48cc34c..d582ffb 100644 --- a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py +++ b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py @@ -133,7 +133,7 @@ def main(): logger.error("Expected %s %s", exp_desc, exp_rc) if status != PASS: - logger.error("------ FAILED: %s %s ------", cn, tc) + logger.error("------ FAILED: %s ------", cn) break vsxml.undefine(server) diff --git a/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py b/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py index d06778e..6215684 100644 --- a/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py +++ b/suites/libvirt-cim/cimtest/ResourcePool/02_rp_gi_errors.py @@ -94,7 +94,7 @@ def main(): logger.error("Expected %s %s", exp_desc, exp_rc) if status != PASS: - logger.error("------ FAILED: %s %s ------", cn, tc) + logger.error("------ FAILED: %s ------", cn) break return status -- 1.8.3.1 From jferlan at redhat.com Thu Aug 8 22:16:40 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 8 Aug 2013 18:16:40 -0400 Subject: [Libvirt-cim] [PATCH 1/3] Allow adding bridged network for running domain In-Reply-To: <1376000202-20533-1-git-send-email-jferlan@redhat.com> References: <1376000202-20533-1-git-send-email-jferlan@redhat.com> Message-ID: <1376000202-20533-2-git-send-email-jferlan@redhat.com> Test failed with following: VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging") ERROR - Error invoking AddRS: add_net_res ERROR - AddResourceSettings call failed ERROR - Failed to destroy Virtual Network 'my_network1' InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging Bug:<00015> The fix for this was that the domain needed to be created with the "acpi=True" flag. This allowed the test to get a bit further, but it then failed with the following: VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL ERROR - Got 88:aa:bb:cc:ee:ff, exp 88:aa:bb:cc:ee:ff. Got None, exp my_network1. ERROR - Error invoking AddRS: add_net_res ERROR - Error adding rs for net mac ERROR - Failed to destroy Virtual Network 'my_network1' The issue here is that the created network bridge doesn't have an xml resource "source network" as 'my_network1', rather that name is assigned to the pool. A network bridge type object has a resource "source bridge" which correlates to the 'virt_net' attribute while network type object correlates to the 'net_name' attribute. Since I wasn't sure how a Xen domain would look I separated the validation comparisons --- .../22_addmulti_brg_interface.py | 9 +++++++-- suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 23 +++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py index 36d1873..0452bf6 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py @@ -63,8 +63,13 @@ def main(): service = get_vsms_class(options.virt)(options.ip) classname = get_typed_class(options.virt, 'VirtualSystemSettingData') - vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, - net_name=default_brg) + # Seems ACPI needs to be set for KVM in order for hotplug to work right + if options.virt == "KVM": + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg, acpi=True) + else: + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg) try: ret = vsxml.cim_define(options.ip) if not ret: diff --git a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py index 075c09f..3c3d0fc 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py @@ -189,9 +189,22 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): % attr['nmac']) if virt == "KVM": - name = cxml.get_value_xpath( + # For KVM bridge types, compare the source bridge + if attr['ntype'] == 'bridge': + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@bridge[. = "%s"]' + % attr['virt_net']) + attr_name = attr['virt_net'] + # For KVM network types, compare the network name + else: + name = cxml.get_value_xpath( '/domain/devices/interface/source/@network[. = "%s"]' % attr['net_name']) + attr_name = attr['net_name'] + if mac != attr['nmac'] or name != attr_name: + logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s.", + mac, attr['nmac'], name, attr['virt_net']) + raise Exception('Error adding rs for net mac') else: # For Xen, network interfaces are converted to bridge interfaces. @@ -202,10 +215,10 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): if name != None: name = attr['net_name'] - if mac != attr['nmac'] or name != attr['net_name']: - logger.error("Got %s, exp %s. Got %s, exp %s.", mac, - attr['nmac'], name, attr['net_name']) - raise Exception('Error adding rs for net mac') + if mac != attr['nmac'] or name != attr['net_name']: + logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s. br %s", + mac, attr['nmac'], name, attr['net_name'], br) + raise Exception('Error adding rs for net mac') logger.info('good status for net_mac') except Exception, details: -- 1.8.3.1 From jferlan at redhat.com Thu Aug 8 22:19:35 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 8 Aug 2013 18:19:35 -0400 Subject: [Libvirt-cim] [PATCH 1/2] spec: Replace the path to the tar.gz file In-Reply-To: <1376000376-20978-1-git-send-email-jferlan@redhat.com> References: <1376000376-20978-1-git-send-email-jferlan@redhat.com> Message-ID: <1376000376-20978-2-git-send-email-jferlan@redhat.com> Commit '07adabc2' seems to have inadvertently removed the path to the source ftp file added by commit '5412bf11'. --- libvirt-cim.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index 7b6221e..dbee4dc 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -6,7 +6,7 @@ Version: @PACKAGE_VERSION@ Release: 1%{?dist}%{?extra_release} License: LGPLv2+ Group: Development/Libraries -Source: libvirt-cim-%{version}.tar.gz +Source: ftp://libvirt.org/libvirt-cim/libvirt-cim-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root URL: http://libvirt.org/CIM/ Requires: libxml2 >= 2.6.0 -- 1.8.3.1 From jferlan at redhat.com Thu Aug 8 22:19:34 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 8 Aug 2013 18:19:34 -0400 Subject: [Libvirt-cim] [PATCH 0/2] Address a couple of spec file issues Message-ID: <1376000376-20978-1-git-send-email-jferlan@redhat.com> These patches resolve a couple of issues with the spec file. John Ferlan (2): spec: Replace the path to the tar.gz file spec: Fix capitalization for version check libvirt-cim.spec.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 1.8.3.1 From jferlan at redhat.com Thu Aug 8 22:19:36 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 8 Aug 2013 18:19:36 -0400 Subject: [Libvirt-cim] [PATCH 2/2] spec: Fix capitalization for version check In-Reply-To: <1376000376-20978-1-git-send-email-jferlan@redhat.com> References: <1376000376-20978-1-git-send-email-jferlan@redhat.com> Message-ID: <1376000376-20978-3-git-send-email-jferlan@redhat.com> "Fedora" shouldn't have been capitalized in the check to use systemctl instead of /etc/init.d/tog-pegasus --- libvirt-cim.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index dbee4dc..d30c198 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -89,7 +89,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/install_base_schema.sh %{_datadir}/%{name} -%if 0%{?Fedora} >= 17 || 0%{?rhel} >= 7 +%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 if [ "`systemctl is-active tog-pegasus.service`" = "active" ] then systemctl restart tog-pegasus.service -- 1.8.3.1 From jferlan at redhat.com Thu Aug 8 22:25:36 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 08 Aug 2013 18:25:36 -0400 Subject: [Libvirt-cim] [PATCH] libcmpiutil: Fix endianness issues in embedded object parsing In-Reply-To: <1375968473-12020-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1375968473-12020-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <52041AE0.2020108@redhat.com> On 08/08/2013 09:27 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > The auxiliary functions _set_int_prop/parse_int_property only > worked on little-endian archs as they performed an incorrect > reinterpretation of 64bit integers. Fixed by using the proper > CMPIValue union fields. > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > --- > eo_parser.c | 35 ++++++++++++++++++++++------------- > eo_parser_xml.c | 49 +++++++++++++++++++++++++++++++++++++++---------- > 2 files changed, 61 insertions(+), 23 deletions(-) > Seems fine to me... I assume one author and one reviewer, right? I'd say push away. John From jmiao at redhat.com Fri Aug 9 05:39:28 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Fri, 9 Aug 2013 01:39:28 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <5203F96C.8050206@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> Message-ID: <1118679694.13820230.1376026768913.JavaMail.root@redhat.com> ----- Original Message ----- > I'm not the expert here - how would I know whether this works? > > I read the README, ran make but it didn't succeed: > > # make > chmod +x xmt-convert.sh > (cd xm-test && sh ../xmt-convert.sh `basename xm-test/initrd-1.1-i386.img`) > 1856 blocks > if uname -r | grep -q xen; then \ > cp /boot/vmlinuz-`uname -r` /var/lib/libvirt/images/default-xen-kernel; \ > fi > chmod +x xmt-makefv.sh > ./xmt-makefv.sh xm-test/xm-test.gz xm-test/xmt_disk.img > Warning: The resulting partition is not properly aligned for best > performance. > FAILED: No kver 0-rescue-9481a187403f46b38d535cf9ffa1cc20 > make: *** [xm-test/xmt_disk.img] Error 1 Do you apply this patch, and it returns this error? According to the error "FAILED: No kver 0-rescue-9481a187403f46b38d535cf9ffa1cc20", I think it is failed at copy_in_kernel() in xmt-makefv.sh, that is not what I modified. In another word, it will be failed without this patch. Jincheng Miao From jmiao at redhat.com Fri Aug 9 06:02:41 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Fri, 9 Aug 2013 02:02:41 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <5203F96C.8050206@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> Message-ID: <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> ----- Original Message ----- > I'm not the expert here - how would I know whether this works? > > I read the README, ran make but it didn't succeed: > > # make > chmod +x xmt-convert.sh > (cd xm-test && sh ../xmt-convert.sh `basename xm-test/initrd-1.1-i386.img`) > 1856 blocks > if uname -r | grep -q xen; then \ > cp /boot/vmlinuz-`uname -r` /var/lib/libvirt/images/default-xen-kernel; \ > fi > chmod +x xmt-makefv.sh > ./xmt-makefv.sh xm-test/xm-test.gz xm-test/xmt_disk.img > Warning: The resulting partition is not properly aligned for best > performance. > FAILED: No kver 0-rescue-9481a187403f46b38d535cf9ffa1cc20 > make: *** [xm-test/xmt_disk.img] Error 1 hmm, for this error, xmt-makefv.sh fails to find the kernel image in your os. In kernel_path() of xmt-makefv, it uses "find /boot | grep vmlinuz | egrep -v 'xen|hmac'| tail -n1" to get image path. The error you met maybe that your kernel image lacks hmac (a signature). From mihajlov at linux.vnet.ibm.com Fri Aug 9 06:19:40 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 09 Aug 2013 08:19:40 +0200 Subject: [Libvirt-cim] [PATCH] libcmpiutil: Fix endianness issues in embedded object parsing In-Reply-To: <52041AE0.2020108@redhat.com> References: <1375968473-12020-1-git-send-email-mihajlov@linux.vnet.ibm.com> <52041AE0.2020108@redhat.com> Message-ID: <520489FC.9000800@linux.vnet.ibm.com> On 08/09/2013 12:25 AM, John Ferlan wrote: > On 08/08/2013 09:27 AM, Viktor Mihajlovski wrote: >> From: Thilo Boehm >> >> The auxiliary functions _set_int_prop/parse_int_property only >> worked on little-endian archs as they performed an incorrect >> reinterpretation of 64bit integers. Fixed by using the proper >> CMPIValue union fields. >> >> Signed-off-by: Thilo Boehm >> Signed-off-by: Viktor Mihajlovski >> --- >> eo_parser.c | 35 ++++++++++++++++++++++------------- >> eo_parser_xml.c | 49 +++++++++++++++++++++++++++++++++++++++---------- >> 2 files changed, 61 insertions(+), 23 deletions(-) >> > > Seems fine to me... I assume one author and one reviewer, right? Right, Thilo is the principal author and I have applied only minor editorial changes to the commit message (hence my signoff). > I'd say push away. Thanks, but I fear I am depending on your kind help here ;-). As a heads up: this patch is - so to speak - a portent of more (mainly but not only s390 arch related) to come. Unfortunately we were not able to make it in time for the recent release. -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Fri Aug 9 10:32:17 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 09 Aug 2013 06:32:17 -0400 Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> Message-ID: <5204C531.1030402@redhat.com> On 08/09/2013 02:02 AM, Jincheng Miao wrote: > ----- Original Message ----- >> I'm not the expert here - how would I know whether this works? >> >> I read the README, ran make but it didn't succeed: >> >> # make >> chmod +x xmt-convert.sh >> (cd xm-test && sh ../xmt-convert.sh `basename xm-test/initrd-1.1-i386.img`) >> 1856 blocks >> if uname -r | grep -q xen; then \ >> cp /boot/vmlinuz-`uname -r` /var/lib/libvirt/images/default-xen-kernel; \ >> fi >> chmod +x xmt-makefv.sh >> ./xmt-makefv.sh xm-test/xm-test.gz xm-test/xmt_disk.img >> Warning: The resulting partition is not properly aligned for best >> performance. >> FAILED: No kver 0-rescue-9481a187403f46b38d535cf9ffa1cc20 >> make: *** [xm-test/xmt_disk.img] Error 1 > > hmm, for this error, xmt-makefv.sh fails to find the kernel image in your os. > > In kernel_path() of xmt-makefv, > it uses "find /boot | grep vmlinuz | egrep -v 'xen|hmac'| tail -n1" to get image path. > > The error you met maybe that your kernel image lacks hmac (a signature). > I understand the error I saw wasn't in the area you changed. I don't believe my run got to the code you changed and as much as it seems like an ACK would be in order, I couldn't test your portion of the change on my host. John FWIW: I have a f19 host # find /boot | grep vmlinuz /boot/.vmlinuz-3.9.11-200.fc18.x86_64.hmac /boot/vmlinuz-3.9.6-200.fc18.x86_64 /boot/.vmlinuz-3.9.6-200.fc18.x86_64.hmac /boot/vmlinuz-3.9.11-200.fc18.x86_64 /boot/vmlinuz-3.9.5-201.fc18.x86_64 /boot/vmlinuz-3.10.4-300.fc19.x86_64 /boot/.vmlinuz-3.9.5-201.fc18.x86_64.hmac /boot/.vmlinuz-3.10.4-300.fc19.x86_64.hmac /boot/vmlinuz-0-rescue-9481a187403f46b38d535cf9ffa1cc20 # find /boot | grep vmlinuz | egrep -v 'xen|hmac' /boot/vmlinuz-3.9.6-200.fc18.x86_64 /boot/vmlinuz-3.9.11-200.fc18.x86_64 /boot/vmlinuz-3.9.5-201.fc18.x86_64 /boot/vmlinuz-3.10.4-300.fc19.x86_64 /boot/vmlinuz-0-rescue-9481a187403f46b38d535cf9ffa1cc20 From jferlan at redhat.com Fri Aug 9 10:38:01 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 09 Aug 2013 06:38:01 -0400 Subject: [Libvirt-cim] [PATCH] libcmpiutil: Fix endianness issues in embedded object parsing In-Reply-To: <520489FC.9000800@linux.vnet.ibm.com> References: <1375968473-12020-1-git-send-email-mihajlov@linux.vnet.ibm.com> <52041AE0.2020108@redhat.com> <520489FC.9000800@linux.vnet.ibm.com> Message-ID: <5204C689.1070404@redhat.com> On 08/09/2013 02:19 AM, Viktor Mihajlovski wrote: > On 08/09/2013 12:25 AM, John Ferlan wrote: >> On 08/08/2013 09:27 AM, Viktor Mihajlovski wrote: >>> From: Thilo Boehm >>> >>> The auxiliary functions _set_int_prop/parse_int_property only >>> worked on little-endian archs as they performed an incorrect >>> reinterpretation of 64bit integers. Fixed by using the proper >>> CMPIValue union fields. >>> >>> Signed-off-by: Thilo Boehm >>> Signed-off-by: Viktor Mihajlovski >>> --- >>> eo_parser.c | 35 ++++++++++++++++++++++------------- >>> eo_parser_xml.c | 49 >>> +++++++++++++++++++++++++++++++++++++++---------- >>> 2 files changed, 61 insertions(+), 23 deletions(-) >>> >> >> Seems fine to me... I assume one author and one reviewer, right? > Right, Thilo is the principal author and I have applied only minor > editorial changes to the commit message (hence my signoff). >> I'd say push away. > Thanks, but I fear I am depending on your kind help here ;-). > > As a heads up: this patch is - so to speak - a portent of more > (mainly but not only s390 arch related) to come. Unfortunately > we were not able to make it in time for the recent release. > I pushed the change after making an edit to remove the trailing white space in a few lines of eo_parser_xml.c (each of the case #: entries had trailing white space and git am complains). John From jmiao at redhat.com Fri Aug 9 11:27:26 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Fri, 9 Aug 2013 07:27:26 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <5204C531.1030402@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> <5204C531.1030402@redhat.com> Message-ID: <89639612.13999163.1376047646198.JavaMail.root@redhat.com> ----- Original Message ----- > I understand the error I saw wasn't in the area you changed. I don't > believe my run got to the code you changed and as much as it seems like > an ACK would be in order, I couldn't test your portion of the change on > my host. > > John > > > FWIW: > > I have a f19 host > > > # find /boot | grep vmlinuz > /boot/.vmlinuz-3.9.11-200.fc18.x86_64.hmac > /boot/vmlinuz-3.9.6-200.fc18.x86_64 > /boot/.vmlinuz-3.9.6-200.fc18.x86_64.hmac > /boot/vmlinuz-3.9.11-200.fc18.x86_64 > /boot/vmlinuz-3.9.5-201.fc18.x86_64 > /boot/vmlinuz-3.10.4-300.fc19.x86_64 > /boot/.vmlinuz-3.9.5-201.fc18.x86_64.hmac > /boot/.vmlinuz-3.10.4-300.fc19.x86_64.hmac > /boot/vmlinuz-0-rescue-9481a187403f46b38d535cf9ffa1cc20 > > > # find /boot | grep vmlinuz | egrep -v 'xen|hmac' > /boot/vmlinuz-3.9.6-200.fc18.x86_64 > /boot/vmlinuz-3.9.11-200.fc18.x86_64 > /boot/vmlinuz-3.9.5-201.fc18.x86_64 > /boot/vmlinuz-3.10.4-300.fc19.x86_64 > /boot/vmlinuz-0-rescue-9481a187403f46b38d535cf9ffa1cc20 > well, I think the xmt-makefv.sh do not care about rescue images. The command should be " find /boot | grep vmlinuz | egrep -v 'xen|hmac|rescue' ". And I think I can give this patch some modification: Signed-off-by: Jincheng Miao --- suites/libvirt-cim/images/xmt-makefv.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/suites/libvirt-cim/images/xmt-makefv.sh b/suites/libvirt-cim/images/xmt-makefv.sh index 1cf6a0f..85a340c 100755 --- a/suites/libvirt-cim/images/xmt-makefv.sh +++ b/suites/libvirt-cim/images/xmt-makefv.sh @@ -51,7 +51,7 @@ partition() { local file=$1 $PARTED $file mklabel msdos - $PARTED $file mkpartfs primary ext2 0 $(($SIZE - 1)) + $PARTED $file mkpart primary ext2 0 $(($SIZE - 1)) } mount_partition() { @@ -62,7 +62,10 @@ mount_partition() { losetup /dev/$loopdev $file || die "Failed to losetup $file" kpartx -a /dev/$loopdev || die "Failed to kpartx $loopdev" + sleep 2 + mke2fs -t ext2 /dev/mapper/${loopdev}p1 >/dev/null 2>&1 || die "Failed to mkfs ${loopdev}p1" tune2fs -j /dev/mapper/${loopdev}p1 >/dev/null 2>&1|| die "Failed to add journal" + sleep 2 mount /dev/mapper/${loopdev}p1 $TMPMOUNT || die "Failed to mount ${loopdev}p1" echo $loopdev @@ -86,7 +88,7 @@ copy_in_ramdisk() { kernel_path() { local prefix=$1 - local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac' | tail -n1` + local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac|rescue' | tail if [ -z $image ]; then touch /boot/vmlinuz-$DUMMY_PATH -- 1.8.3.1 From jmiao at redhat.com Fri Aug 9 11:30:48 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Fri, 9 Aug 2013 07:30:48 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <89639612.13999163.1376047646198.JavaMail.root@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> <5204C531.1030402@redhat.com> <89639612.13999163.1376047646198.JavaMail.root@redhat.com> Message-ID: <1725558155.14000435.1376047848436.JavaMail.root@redhat.com> Sorry, there is a error when I paste patch. The correct patch is : Signed-off-by: Jincheng Miao --- suites/libvirt-cim/images/xmt-makefv.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/suites/libvirt-cim/images/xmt-makefv.sh b/suites/libvirt-cim/images/xmt-makefv.sh index 1cf6a0f..85a340c 100755 --- a/suites/libvirt-cim/images/xmt-makefv.sh +++ b/suites/libvirt-cim/images/xmt-makefv.sh @@ -51,7 +51,7 @@ partition() { local file=$1 $PARTED $file mklabel msdos - $PARTED $file mkpartfs primary ext2 0 $(($SIZE - 1)) + $PARTED $file mkpart primary ext2 0 $(($SIZE - 1)) } mount_partition() { @@ -62,7 +62,10 @@ mount_partition() { losetup /dev/$loopdev $file || die "Failed to losetup $file" kpartx -a /dev/$loopdev || die "Failed to kpartx $loopdev" + sleep 2 + mke2fs -t ext2 /dev/mapper/${loopdev}p1 >/dev/null 2>&1 || die "Failed to mkfs ${loopdev}p1" tune2fs -j /dev/mapper/${loopdev}p1 >/dev/null 2>&1|| die "Failed to add journal" + sleep 2 mount /dev/mapper/${loopdev}p1 $TMPMOUNT || die "Failed to mount ${loopdev}p1" echo $loopdev @@ -86,7 +88,7 @@ copy_in_ramdisk() { kernel_path() { local prefix=$1 - local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac' | tail -n1` + local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac|rescue' | tail -n1` if [ -z $image ]; then touch /boot/vmlinuz-$DUMMY_PATH -- 1.8.3.1 ----- Original Message ----- > well, I think the xmt-makefv.sh do not care about rescue images. > The command should be " find /boot | grep vmlinuz | egrep -v > 'xen|hmac|rescue' ". > > And I think I can give this patch some modification: > > Signed-off-by: Jincheng Miao > --- > suites/libvirt-cim/images/xmt-makefv.sh | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/suites/libvirt-cim/images/xmt-makefv.sh > b/suites/libvirt-cim/images/xmt-makefv.sh > index 1cf6a0f..85a340c 100755 > --- a/suites/libvirt-cim/images/xmt-makefv.sh > +++ b/suites/libvirt-cim/images/xmt-makefv.sh > @@ -51,7 +51,7 @@ partition() { > local file=$1 > > $PARTED $file mklabel msdos > - $PARTED $file mkpartfs primary ext2 0 $(($SIZE - 1)) > + $PARTED $file mkpart primary ext2 0 $(($SIZE - 1)) > } > > mount_partition() { > @@ -62,7 +62,10 @@ mount_partition() { > > losetup /dev/$loopdev $file || die "Failed to losetup $file" > kpartx -a /dev/$loopdev || die "Failed to kpartx $loopdev" > + sleep 2 > + mke2fs -t ext2 /dev/mapper/${loopdev}p1 >/dev/null 2>&1 || die "Failed > to mkfs ${loopdev}p1" > tune2fs -j /dev/mapper/${loopdev}p1 >/dev/null 2>&1|| die "Failed to add > journal" > + sleep 2 > mount /dev/mapper/${loopdev}p1 $TMPMOUNT || die "Failed to mount > ${loopdev}p1" > > echo $loopdev > @@ -86,7 +88,7 @@ copy_in_ramdisk() { > kernel_path() { > local prefix=$1 > > - local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac' | tail -n1` > + local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac|rescue' | > tail > > if [ -z $image ]; then > touch /boot/vmlinuz-$DUMMY_PATH > -- > 1.8.3.1 > From jferlan at redhat.com Fri Aug 9 11:34:03 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 09 Aug 2013 07:34:03 -0400 Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <89639612.13999163.1376047646198.JavaMail.root@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> <5204C531.1030402@redhat.com> <89639612.13999163.1376047646198.JavaMail.root@redhat.com> Message-ID: <5204D3AB.2010501@redhat.com> On 08/09/2013 07:27 AM, Jincheng Miao wrote: > ----- Original Message ----- >> I understand the error I saw wasn't in the area you changed. I don't >> believe my run got to the code you changed and as much as it seems like >> an ACK would be in order, I couldn't test your portion of the change on >> my host. >> >> John >> >> >> FWIW: >> >> I have a f19 host >> >> >> # find /boot | grep vmlinuz >> /boot/.vmlinuz-3.9.11-200.fc18.x86_64.hmac >> /boot/vmlinuz-3.9.6-200.fc18.x86_64 >> /boot/.vmlinuz-3.9.6-200.fc18.x86_64.hmac >> /boot/vmlinuz-3.9.11-200.fc18.x86_64 >> /boot/vmlinuz-3.9.5-201.fc18.x86_64 >> /boot/vmlinuz-3.10.4-300.fc19.x86_64 >> /boot/.vmlinuz-3.9.5-201.fc18.x86_64.hmac >> /boot/.vmlinuz-3.10.4-300.fc19.x86_64.hmac >> /boot/vmlinuz-0-rescue-9481a187403f46b38d535cf9ffa1cc20 >> >> >> # find /boot | grep vmlinuz | egrep -v 'xen|hmac' >> /boot/vmlinuz-3.9.6-200.fc18.x86_64 >> /boot/vmlinuz-3.9.11-200.fc18.x86_64 >> /boot/vmlinuz-3.9.5-201.fc18.x86_64 >> /boot/vmlinuz-3.10.4-300.fc19.x86_64 >> /boot/vmlinuz-0-rescue-9481a187403f46b38d535cf9ffa1cc20 >> > > well, I think the xmt-makefv.sh do not care about rescue images. > The command should be " find /boot | grep vmlinuz | egrep -v 'xen|hmac|rescue' ". > > And I think I can give this patch some modification: > > Signed-off-by: Jincheng Miao > --- > suites/libvirt-cim/images/xmt-makefv.sh | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/suites/libvirt-cim/images/xmt-makefv.sh b/suites/libvirt-cim/images/xmt-makefv.sh > index 1cf6a0f..85a340c 100755 > --- a/suites/libvirt-cim/images/xmt-makefv.sh > +++ b/suites/libvirt-cim/images/xmt-makefv.sh > @@ -51,7 +51,7 @@ partition() { > local file=$1 > > $PARTED $file mklabel msdos > - $PARTED $file mkpartfs primary ext2 0 $(($SIZE - 1)) > + $PARTED $file mkpart primary ext2 0 $(($SIZE - 1)) > } > > mount_partition() { > @@ -62,7 +62,10 @@ mount_partition() { > > losetup /dev/$loopdev $file || die "Failed to losetup $file" > kpartx -a /dev/$loopdev || die "Failed to kpartx $loopdev" > + sleep 2 > + mke2fs -t ext2 /dev/mapper/${loopdev}p1 >/dev/null 2>&1 || die "Failed to mkfs ${loopdev}p1" > tune2fs -j /dev/mapper/${loopdev}p1 >/dev/null 2>&1|| die "Failed to add journal" > + sleep 2 > mount /dev/mapper/${loopdev}p1 $TMPMOUNT || die "Failed to mount ${loopdev}p1" > > echo $loopdev > @@ -86,7 +88,7 @@ copy_in_ramdisk() { > kernel_path() { > local prefix=$1 > > - local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac' | tail -n1` > + local image=`find /boot | grep vmlinuz | egrep -v 'xen|hmac|rescue' | tail > > if [ -z $image ]; then > touch /boot/vmlinuz-$DUMMY_PATH > Yep - that works. I suppose you need me to push right? John From jmiao at redhat.com Fri Aug 9 11:57:46 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Fri, 9 Aug 2013 07:57:46 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <5204D3AB.2010501@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> <5204C531.1030402@redhat.com> <89639612.13999163.1376047646198.JavaMail.root@redhat.com> <5204D3AB.2010501@redhat.com> Message-ID: <1298543863.14003505.1376049466032.JavaMail.root@redhat.com> ----- Original Message ----- > Yep - that works. > > I suppose you need me to push right? > > John > Yes, John, I think I need the right to push my patch. Thank you very much Sincerely Jincheng Miao From mihajlov at linux.vnet.ibm.com Fri Aug 9 11:58:47 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 09 Aug 2013 13:58:47 +0200 Subject: [Libvirt-cim] [PATCH] libcmpiutil: Fix endianness issues in embedded object parsing In-Reply-To: <5204C689.1070404@redhat.com> References: <1375968473-12020-1-git-send-email-mihajlov@linux.vnet.ibm.com> <52041AE0.2020108@redhat.com> <520489FC.9000800@linux.vnet.ibm.com> <5204C689.1070404@redhat.com> Message-ID: <5204D977.4040307@linux.vnet.ibm.com> On 08/09/2013 12:38 PM, John Ferlan wrote: > > I pushed the change after making an edit to remove the trailing white > space in a few lines of eo_parser_xml.c (each of the case #: entries had > trailing white space and git am complains). thanks and sorry for the extra effort. I will be more careful in the future (never thought I'd be missing make syntax-check). -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jmiao at redhat.com Fri Aug 9 12:09:10 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Fri, 9 Aug 2013 08:09:10 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] cimtest: fix guest images generation In-Reply-To: <5204D3AB.2010501@redhat.com> References: <1375546457-2946-1-git-send-email-jmiao@redhat.com> <5203F96C.8050206@redhat.com> <1504881337.13828615.1376028161353.JavaMail.root@redhat.com> <5204C531.1030402@redhat.com> <89639612.13999163.1376047646198.JavaMail.root@redhat.com> <5204D3AB.2010501@redhat.com> Message-ID: <1726214507.14006902.1376050150582.JavaMail.root@redhat.com> ----- Original Message ----- > Yep - that works. > > I suppose you need me to push right? uh, do I mis-understand "push right"? Is it "push, right" ? > > John > From gesaint at linux.vnet.ibm.com Thu Aug 15 06:40:07 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Thu, 15 Aug 2013 14:40:07 +0800 Subject: [Libvirt-cim] [PATCH V2] Add dumpCore tag support to memory Message-ID: <1376548807-23815-1-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 26 +++++++++++++++++++++++++- libxkutil/device_parsing.h | 1 + libxkutil/xmlgen.c | 4 ++++ 3 files changed, 30 insertions(+), 1 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 7900e06..23fa6d4 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -141,6 +141,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); } +static void cleanup_mem_device(struct mem_device *dev) +{ + if (dev == NULL) + return; + + if (dev->dumpCore) + free(dev->dumpCore); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -156,6 +165,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_graphics_device(&dev->dev.graphics); else if (dev->type == CIM_RES_TYPE_INPUT) cleanup_input_device(&dev->dev.input); + else if (dev->type == CIM_RES_TYPE_MEM) + cleanup_mem_device(&dev->dev.mem); free(dev->id); @@ -605,8 +616,10 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) if (XSTREQ(node->name, "currentMemory")) sscanf(content, "%" PRIu64, &mdev->size); - else if (XSTREQ(node->name, "memory")) + else if (XSTREQ(node->name, "memory")) { sscanf(content, "%" PRIu64, &mdev->maxsize); + mdev->dumpCore = get_attr_value(node, "dumpCore"); + } free(content); @@ -987,10 +1000,21 @@ static int _get_mem_device(const char *xml, struct virt_device **list) mdevs[1].dev.mem.size); mdev->dev.mem.maxsize = MAX(mdevs[0].dev.mem.maxsize, mdevs[1].dev.mem.maxsize); + /* If both of them have dumpCore field, the first one + * will be saved. If one of them has that field, it will + * be saved too. If none of them has that field, the + * value will be left null. + */ + if (mdevs[0].dev.mem.dumpCore) { + mdev->dev.mem.dumpCore = strdup(mdevs[0].dev.mem.dumpCore); + } else if (mdevs[1].dev.mem.dumpCore) { + mdev->dev.mem.dumpCore = strdup(mdevs[1].dev.mem.dumpCore); + } } else { mdev->dev.mem.size = MAX(mdevs[0].dev.mem.size, mdevs[0].dev.mem.maxsize); mdev->dev.mem.maxsize = mdev->dev.mem.size; + mdev->dev.mem.dumpCore = strdup(mdevs[0].dev.mem.dumpCore); } mdev->type = CIM_RES_TYPE_MEM; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 2b6d3d1..73810c9 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -75,6 +75,7 @@ struct net_device { struct mem_device { uint64_t size; uint64_t maxsize; + char *dumpCore; }; struct vcpu_device { diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 4287d42..7c16657 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -498,6 +498,10 @@ static const char *mem_xml(xmlNodePtr root, struct domain *dominfo) BAD_CAST string); free(string); + + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST mem->dumpCore); out: if (tmp == NULL) return XML_ERROR; -- 1.7.1 From gesaint at linux.vnet.ibm.com Thu Aug 15 06:40:24 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Thu, 15 Aug 2013 14:40:24 +0800 Subject: [Libvirt-cim] [PATCH V2] Add dumpCore tag support to memory Message-ID: <1376548824-23848-1-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 26 +++++++++++++++++++++++++- libxkutil/device_parsing.h | 1 + libxkutil/xmlgen.c | 4 ++++ 3 files changed, 30 insertions(+), 1 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 7900e06..23fa6d4 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -141,6 +141,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); } +static void cleanup_mem_device(struct mem_device *dev) +{ + if (dev == NULL) + return; + + if (dev->dumpCore) + free(dev->dumpCore); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -156,6 +165,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_graphics_device(&dev->dev.graphics); else if (dev->type == CIM_RES_TYPE_INPUT) cleanup_input_device(&dev->dev.input); + else if (dev->type == CIM_RES_TYPE_MEM) + cleanup_mem_device(&dev->dev.mem); free(dev->id); @@ -605,8 +616,10 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) if (XSTREQ(node->name, "currentMemory")) sscanf(content, "%" PRIu64, &mdev->size); - else if (XSTREQ(node->name, "memory")) + else if (XSTREQ(node->name, "memory")) { sscanf(content, "%" PRIu64, &mdev->maxsize); + mdev->dumpCore = get_attr_value(node, "dumpCore"); + } free(content); @@ -987,10 +1000,21 @@ static int _get_mem_device(const char *xml, struct virt_device **list) mdevs[1].dev.mem.size); mdev->dev.mem.maxsize = MAX(mdevs[0].dev.mem.maxsize, mdevs[1].dev.mem.maxsize); + /* If both of them have dumpCore field, the first one + * will be saved. If one of them has that field, it will + * be saved too. If none of them has that field, the + * value will be left null. + */ + if (mdevs[0].dev.mem.dumpCore) { + mdev->dev.mem.dumpCore = strdup(mdevs[0].dev.mem.dumpCore); + } else if (mdevs[1].dev.mem.dumpCore) { + mdev->dev.mem.dumpCore = strdup(mdevs[1].dev.mem.dumpCore); + } } else { mdev->dev.mem.size = MAX(mdevs[0].dev.mem.size, mdevs[0].dev.mem.maxsize); mdev->dev.mem.maxsize = mdev->dev.mem.size; + mdev->dev.mem.dumpCore = strdup(mdevs[0].dev.mem.dumpCore); } mdev->type = CIM_RES_TYPE_MEM; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 2b6d3d1..73810c9 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -75,6 +75,7 @@ struct net_device { struct mem_device { uint64_t size; uint64_t maxsize; + char *dumpCore; }; struct vcpu_device { diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 4287d42..7c16657 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -498,6 +498,10 @@ static const char *mem_xml(xmlNodePtr root, struct domain *dominfo) BAD_CAST string); free(string); + + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST mem->dumpCore); out: if (tmp == NULL) return XML_ERROR; -- 1.7.1 From mihajlov at linux.vnet.ibm.com Thu Aug 15 14:48:18 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 15 Aug 2013 16:48:18 +0200 Subject: [Libvirt-cim] [PATCH 0/4] Initial Enablement of S390 Message-ID: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> The current libvirt-cim implementation makes some assumptions that are only true for x86 architectures. As we want to enable libvirt-cim for s390 we need to makes sure that valid libvirt guest definitions are being built for that architecture while not breaking the existing implementation. Patches 1 and 2 introduce two new properties arch and machine, effectively a pass-through of the underlying libvirt properties, for the necessary distinction between x86 and other guests, and suppress the default framebuffer for s390. Patches 3 and 4 make sure that a minimal SVPC guest definition (VSSD and RASD) will result in a correct libvirt guest definition for the current hypervisor. Boris Fiuczynski (2): libxkutil: Provide easy access to the libvirt capabilities VSSM: Set default values based on libvirt capabilities on DefineSystem calls Viktor Mihajlovski (2): VSSD: Add properties for arch and machine S390: Avoid the generation of default input and graphics libxkutil/Makefile.am | 2 + libxkutil/capability_parsing.c | 462 +++++++++++++++++++++++++++++ libxkutil/capability_parsing.h | 93 ++++++ libxkutil/device_parsing.c | 85 ++++-- libxkutil/device_parsing.h | 2 + libxkutil/xml_parse_test.c | 134 ++++++++- libxkutil/xmlgen.c | 6 + schema/VSSD.mof | 6 + src/Virt_VSSD.c | 9 + src/Virt_VirtualSystemManagementService.c | 128 ++++---- 10 files changed, 842 insertions(+), 85 deletions(-) create mode 100644 libxkutil/capability_parsing.c create mode 100644 libxkutil/capability_parsing.h -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 15 14:48:21 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 15 Aug 2013 16:48:21 +0200 Subject: [Libvirt-cim] [PATCH 3/4] libxkutil: Provide easy access to the libvirt capabilities In-Reply-To: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1376578102-2909-4-git-send-email-mihajlov@linux.vnet.ibm.com> From: Boris Fiuczynski Introspecting the libvirt capabilities and creating an internal capabilities data structure. Methods are provided for retrieving default values regarding architecture, machine and emulator for easy of use in the provider code. Further, xml_parse_test was extendend to display hypervisor capabilities and defaults. Signed-off-by: Boris Fiuczynski Signed-off-by: Viktor Mihajlovski --- libxkutil/Makefile.am | 2 + libxkutil/capability_parsing.c | 462 ++++++++++++++++++++++++++++++++++++++++ libxkutil/capability_parsing.h | 93 ++++++++ libxkutil/xml_parse_test.c | 134 +++++++++++- 4 files changed, 688 insertions(+), 3 deletions(-) create mode 100644 libxkutil/capability_parsing.c create mode 100644 libxkutil/capability_parsing.h diff --git a/libxkutil/Makefile.am b/libxkutil/Makefile.am index 8d436ad..dd7be55 100644 --- a/libxkutil/Makefile.am +++ b/libxkutil/Makefile.am @@ -7,6 +7,7 @@ noinst_HEADERS = \ cs_util.h \ misc_util.h \ device_parsing.h \ + capability_parsing.h \ xmlgen.h \ infostore.h \ pool_parsing.h \ @@ -20,6 +21,7 @@ libxkutil_la_SOURCES = \ cs_util_instance.c \ misc_util.c \ device_parsing.c \ + capability_parsing.c \ xmlgen.c \ infostore.c \ pool_parsing.c \ diff --git a/libxkutil/capability_parsing.c b/libxkutil/capability_parsing.c new file mode 100644 index 0000000..2185584 --- /dev/null +++ b/libxkutil/capability_parsing.c @@ -0,0 +1,462 @@ +/* + * Copyright IBM Corp. 2013 + * + * Authors: + * Boris Fiuczynski + * + * 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 "misc_util.h" +#include "capability_parsing.h" +#include "xmlgen.h" +#include "../src/svpc_types.h" + +static void cleanup_cap_machine(struct cap_machine *machine) +{ + if (machine == NULL) + return; + free(machine->name); + free(machine->canonical_name); +} + +void cleanup_cap_domain_info(struct cap_domain_info *cgdi) +{ + int i; + if (cgdi == NULL) + return; + free(cgdi->emulator); + free(cgdi->loader); + for (i = 0; i < cgdi->num_machines; i++) + cleanup_cap_machine(&cgdi->machines[i]); + free(cgdi->machines); +} + +static void cleanup_cap_domain(struct cap_domain *cgd) +{ + if (cgd == NULL) + return; + free(cgd->typestr); + cleanup_cap_domain_info(&cgd->guest_domain_info); +} + +static void cleanup_cap_arch(struct cap_arch *cga) +{ + int i; + if (cga == NULL) + return; + free(cga->name); + cleanup_cap_domain_info(&cga->default_domain_info); + for (i = 0; i < cga->num_domains; i++) + cleanup_cap_domain(&cga->domains[i]); + free(cga->domains); +} + +void cleanup_cap_guest(struct cap_guest *cg) +{ + if (cg == NULL) + return; + free(cg->ostype); + cleanup_cap_arch(&cg->arch); +} + +static void extend_cap_machines(struct cap_domain_info *cg_domaininfo, + char *name, char *canonical_name) +{ + struct cap_machine *tmp_list = NULL; + tmp_list = realloc(cg_domaininfo->machines, + (cg_domaininfo->num_machines + 1) * + sizeof(struct cap_machine)); + + if (tmp_list == NULL) { + /* Nothing you can do. Just go on. */ + CU_DEBUG("Could not alloc space for " + "guest domain info list"); + return; + } + cg_domaininfo->machines = tmp_list; + + struct cap_machine *cap_gm = + &cg_domaininfo->machines[cg_domaininfo->num_machines]; + cap_gm->name = name; + cap_gm->canonical_name = canonical_name; + cg_domaininfo->num_machines++; +} + +static void parse_cap_domain_info(struct cap_domain_info *cg_domaininfo, + xmlNode *domain_child_node) +{ + CU_DEBUG("Capabilities guest domain info element node: %s", + domain_child_node->name); + + if (XSTREQ(domain_child_node->name, "emulator")) { + cg_domaininfo->emulator = + get_node_content(domain_child_node); + } else if (XSTREQ(domain_child_node->name, "loader")) { + cg_domaininfo->loader = + get_node_content(domain_child_node); + } else if (XSTREQ(domain_child_node->name, "machine")) { + extend_cap_machines(cg_domaininfo, + get_node_content(domain_child_node), + get_attr_value(domain_child_node, + "canonical")); + } +} + +static void parse_cap_domain(struct cap_domain *cg_domain, + xmlNode *guest_dom) +{ + CU_DEBUG("Capabilities guest domain node: %s", guest_dom->name); + + xmlNode *child; + + cg_domain->typestr = get_attr_value(guest_dom, "type"); + + for (child = guest_dom->children; child != NULL; child = child->next) + parse_cap_domain_info(&cg_domain->guest_domain_info, child); +} + +static void parse_cap_arch(struct cap_arch *cg_archinfo, + xmlNode *arch) +{ + CU_DEBUG("Capabilities arch node: %s", arch->name); + + xmlNode *child; + + cg_archinfo->name = get_attr_value(arch, "name"); + + for (child = arch->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "wordsize")) { + char *wordsize_str; + unsigned int wordsize; + wordsize_str = get_node_content(child); + /* Default to 0 wordsize if garbage */ + if (wordsize_str == NULL || + sscanf(wordsize_str, "%i", &wordsize) != 1) + wordsize = 0; + free(wordsize_str); + cg_archinfo->wordsize = wordsize; + } else if (XSTREQ(child->name, "domain")) { + struct cap_domain *tmp_list = NULL; + tmp_list = realloc(cg_archinfo->domains, + (cg_archinfo->num_domains + 1) * + sizeof(struct cap_domain)); + if (tmp_list == NULL) { + /* Nothing you can do. Just go on. */ + CU_DEBUG("Could not alloc space for " + "guest domain"); + continue; + } + memset(&tmp_list[cg_archinfo->num_domains], + 0, sizeof(struct cap_domain)); + cg_archinfo->domains = tmp_list; + parse_cap_domain(&cg_archinfo-> + domains[cg_archinfo->num_domains], + child); + cg_archinfo->num_domains++; + } else { + /* Check for the default domain child nodes */ + parse_cap_domain_info(&cg_archinfo->default_domain_info, + child); + } + } +} + +static void parse_cap_guests(xmlNodeSet *nsv, struct cap_guest **cap_guests) +{ + xmlNode **nodes = nsv->nodeTab; + xmlNode *child; + int numGuestNodes = nsv->nodeNr; + int i; + + for (i = 0; i < numGuestNodes; i++) { + for (child = nodes[i]->children; child != NULL; + child = child->next) { + if (XSTREQ(child->name, "os_type")) { + STRPROP(cap_guests[i], ostype, child); + } else if (XSTREQ(child->name, "arch")) { + parse_cap_arch(&cap_guests[i]->arch, child); + } + } + } +} + +static void compare_copy_domain_info_machines( + struct cap_domain_info *def_gdomi, + struct cap_domain_info *cap_gadomi) +{ + int i,j; + int org_l = cap_gadomi->num_machines; + char *cp_name = NULL; + char *cp_canonical_name = NULL; + bool found; + + for (i = 0; i < def_gdomi->num_machines; i++) { + found = false; + for (j = 0; j < org_l; j++) { + if (STREQC(def_gdomi->machines[i].name, + cap_gadomi->machines[j].name)) { + found = true; + continue; + /* found match => check next default */ + } + } + if (!found) { /* no match => insert default */ + cp_name = NULL; + cp_canonical_name = NULL; + if (def_gdomi->machines[i].name != NULL) + cp_name = strdup(def_gdomi->machines[i].name); + if (def_gdomi->machines[i].canonical_name != NULL) + cp_canonical_name = + strdup(def_gdomi-> + machines[i].canonical_name); + + extend_cap_machines(cap_gadomi, + cp_name, + cp_canonical_name); + } + } +} + +static void extend_defaults_cap_guests(struct capabilities *caps) +{ + struct cap_arch *cap_garch; + struct cap_domain_info *cap_gadomi; + struct cap_domain_info *def_gdomi; + int i,j; + + if (caps == NULL) + return; + + for (i = 0; i < caps->num_guests; i++) { + cap_garch = &caps->guests[i].arch; + def_gdomi = &cap_garch->default_domain_info; + + for (j = 0; j < cap_garch->num_domains; j++) { + /* compare guest_domain_info */ + cap_gadomi = &cap_garch->domains[j].guest_domain_info; + if (cap_gadomi->emulator == NULL && + def_gdomi->emulator != NULL) + cap_gadomi->emulator = + strdup(def_gdomi->emulator); + if (cap_gadomi->loader == NULL && + def_gdomi->loader != NULL) + cap_gadomi->loader = strdup(def_gdomi->loader); + + compare_copy_domain_info_machines(def_gdomi, + cap_gadomi); + } + } +} + +static int _get_cap_guests(const char *xml, struct capabilities *caps) +{ + int len; + + xmlDoc *xmldoc = NULL; + xmlXPathContext *xpathctx = NULL; + xmlXPathObject *xpathobj = NULL; + const xmlChar *xpathstr = (xmlChar *)"//capabilities//guest"; + xmlNodeSet *nsv; + + len = strlen(xml) + 1; + + if ((xmldoc = xmlParseMemory(xml, len)) == NULL) + goto err; + + if ((xpathctx = xmlXPathNewContext(xmldoc)) == NULL) + goto err; + + if ((xpathobj = xmlXPathEvalExpression(xpathstr, xpathctx)) == NULL) + goto err; + if (xmlXPathNodeSetIsEmpty(xpathobj->nodesetval)) { + CU_DEBUG("No capabilities guest nodes found!"); + goto err; + } + + nsv = xpathobj->nodesetval; + caps->guests = calloc(nsv->nodeNr, sizeof(struct cap_guest)); + if (caps->guests == NULL) + goto err; + caps->num_guests = nsv->nodeNr; + + parse_cap_guests(nsv, &caps->guests); + extend_defaults_cap_guests(caps); + return 1; + + err: + xmlXPathFreeObject(xpathobj); + xmlXPathFreeContext(xpathctx); + xmlFreeDoc(xmldoc); + return 0; +} + +int get_caps_from_xml(const char *xml, struct capabilities **caps) +{ + CU_DEBUG("In get_caps_from_xml"); + + *caps = calloc(1, sizeof(struct capabilities)); + if (*caps == NULL) + goto err; + + if (_get_cap_guests(xml, *caps) == 0) + goto err; + + return 1; + + err: + free(*caps); + *caps = NULL; + return 0; +} + +int get_capabilities(virConnectPtr conn, struct capabilities **caps) +{ + char *caps_xml = NULL; + int ret = 0; + + if (conn == NULL) { + CU_DEBUG("Unable to connect to libvirt."); + return 0; + } + + caps_xml = virConnectGetCapabilities(conn); + + if (caps_xml == NULL) { + CU_DEBUG("Unable to get capabilities xml."); + return 0; + } + + ret = get_caps_from_xml(caps_xml, caps); + + free(caps_xml); + + return ret; +} + +struct cap_domain_info *findDomainInfo(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type) +{ + int i,j; + struct cap_arch *ar; + for (i = 0; i < caps->num_guests; i++) { + if (os_type == NULL || + STREQC(caps->guests[i].ostype, os_type)) { + ar = &caps->guests[i].arch; + if (arch == NULL || STREQC(ar->name,arch)) + for (j = 0; j < ar->num_domains; j++) + if (domain_type == NULL || + STREQC(ar->domains[j].typestr, + domain_type)) + return &ar->domains[j]. + guest_domain_info; + } + } + return NULL; +} + +char *get_default_arch(struct capabilities *caps, + const char *os_type) +{ + char *ret = NULL; + int i; + + if (caps != NULL) { + if (os_type == NULL) { /* pick first guest */ + if (caps->num_guests > 0) + ret = caps->guests[0].arch.name; + } else { /* search first matching guest */ + for (i = 0; i < caps->num_guests; i++) + if (STREQC(caps->guests[i].ostype, os_type)) { + ret = caps->guests[i].arch.name; + break; + } + } + } + return ret; +} + +char *get_default_machine( + struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type) +{ + char *ret = NULL; + struct cap_domain_info *di; + + if (caps != NULL) { + di = findDomainInfo(caps, os_type, arch, domain_type); + if (di != NULL && di->num_machines > 0) + ret = di->machines[0].canonical_name; + } + return ret; +} + +char *get_default_emulator(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type) +{ + char *ret = NULL; + struct cap_domain_info *di; + + if (caps != NULL) { + di = findDomainInfo(caps, os_type, arch, domain_type); + if (di != NULL) + ret = di->emulator; + } + return ret; +} + +bool use_kvm(struct capabilities *caps) { + if (host_supports_kvm(caps) && !get_disable_kvm()) + return true; + else + return false; +} + +bool host_supports_kvm(struct capabilities *caps) +{ + bool kvm = false; + if (caps != NULL) + if (findDomainInfo(caps, NULL, NULL, "kvm") != NULL) + kvm = true; + return kvm; +} +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/libxkutil/capability_parsing.h b/libxkutil/capability_parsing.h new file mode 100644 index 0000000..13af510 --- /dev/null +++ b/libxkutil/capability_parsing.h @@ -0,0 +1,93 @@ +/* + * Copyright IBM Corp. 2013 + * + * Authors: + * Boris Fiuczynski + * + * 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 + */ +#ifndef __CAPABILITY_PARSING_H +#define __CAPABILITY_PARSING_H + +#include +#include + +struct cap_machine { + char *name; + char *canonical_name; +}; + +struct cap_domain_info { + char *emulator; + char *loader; + int num_machines; + struct cap_machine *machines; +}; + +struct cap_domain { + char *typestr; + struct cap_domain_info guest_domain_info; +}; + +struct cap_arch { + char *name; + unsigned int wordsize; + struct cap_domain_info default_domain_info; + int num_domains; + struct cap_domain *domains; +}; + +struct cap_guest { + char *ostype; + struct cap_arch arch; +}; + +struct capabilities { + int num_guests; + struct cap_guest *guests; +}; + +int get_caps_from_xml(const char *xml, struct capabilities **caps); +int get_capabilities(virConnectPtr conn, struct capabilities **caps); +char *get_default_arch(struct capabilities *caps, + const char *os_type); +char *get_default_machine(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type); +char *get_default_emulator(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type); +struct cap_domain_info *findDomainInfo(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type); +bool use_kvm(struct capabilities *caps); +bool host_supports_kvm(struct capabilities *caps); +void cleanup_cap_guest(struct cap_guest *cg); +void cleanup_cap_domain_info(struct cap_domain_info *cgdi); + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c index 384593d..5c5f2df 100644 --- a/libxkutil/xml_parse_test.c +++ b/libxkutil/xml_parse_test.c @@ -6,6 +6,7 @@ #include #include "device_parsing.h" +#include "capability_parsing.h" #include "xmlgen.h" static void print_value(FILE *d, const char *name, const char *val) @@ -183,6 +184,91 @@ static char *read_from_file(FILE *file) return xml; } +static void print_cap_domain_info(struct cap_domain_info *capgdiinfo, + FILE *d) +{ + struct cap_machine capgminfo; + int i; + + if (capgdiinfo==NULL) + return; + + if (capgdiinfo->emulator!=NULL) + print_value(d, " Emulator", capgdiinfo->emulator); + if (capgdiinfo->loader!=NULL) + print_value(d, " Loader", capgdiinfo->loader); + for (i=0; inum_machines; i++) { + capgminfo = capgdiinfo->machines[i]; + fprintf(d, " Machine name : %-15s canonical name : %s\n", + capgminfo.name, capgminfo.canonical_name); + } + fprintf(d, "\n"); +} + +static void print_cap_domains(struct cap_arch caparchinfo, + FILE *d) +{ + struct cap_domain capgdinfo; + int i; + for (i=0; iostype); + print_cap_arch(capginfo->arch, d); +} + +static void print_capabilities(struct capabilities *capsinfo, + FILE *d) +{ + int i; + fprintf(d, "\n### Capabilities ###\n"); + fprintf(d, "-- Guest (%i) --\n", capsinfo->num_guests); + for (i=0; inum_guests; i++) { + print_cap_guest(&capsinfo->guests[i], d); + } +} + +static int capinfo_for_dom(const char *uri, + struct domain *dominfo, + struct capabilities **capsinfo) +{ + virConnectPtr conn = NULL; + char *caps_xml = NULL; + int ret = 0; + + conn = virConnectOpen(uri); + if (conn == NULL) { + printf("Unable to connect to libvirt\n"); + goto out; + } + + ret = get_capabilities(conn, capsinfo); + + out: + free(caps_xml); + virConnectClose(conn); + + return ret; +} + static int dominfo_from_dom(const char *uri, const char *domain, struct domain **d) @@ -246,12 +332,13 @@ static int dominfo_from_file(const char *fname, struct domain **d) static void usage(void) { printf("xml_parse_test -f [FILE | -] [--xml]\n" - "xml_parse_test -d domain [--uri URI] [--xml]\n" + "xml_parse_test -d domain [--uri URI] [--xml] [--cap]\n" "\n" "-f,--file FILE Parse domain XML from file (or stdin if -)\n" "-d,--domain DOM Display dominfo for a domain from libvirt\n" "-u,--uri URI Connect to libvirt with URI\n" "-x,--xml Dump generated XML instead of summary\n" + "-c,--cap Display the libvirt default capability values for the specified domain\n" "-h,--help Display this help message\n"); } @@ -262,7 +349,10 @@ int main(int argc, char **argv) char *uri = "xen"; char *file = NULL; bool xml = false; + bool cap = false; struct domain *dominfo = NULL; + struct capabilities *capsinfo = NULL; + struct cap_domain_info *capgdinfo = NULL; int ret; static struct option lopts[] = { @@ -270,13 +360,14 @@ int main(int argc, char **argv) {"uri", 1, 0, 'u'}, {"xml", 0, 0, 'x'}, {"file", 1, 0, 'f'}, + {"cap", 0, 0, 'c'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0}}; while (1) { int optidx = 0; - c = getopt_long(argc, argv, "d:u:f:xh", lopts, &optidx); + c = getopt_long(argc, argv, "d:u:f:xch", lopts, &optidx); if (c == -1) break; @@ -297,11 +388,14 @@ int main(int argc, char **argv) xml = true; break; + case 'c': + cap = true; + break; + case '?': case 'h': usage(); return c == '?'; - }; } @@ -326,6 +420,40 @@ int main(int argc, char **argv) print_devices(dominfo, stdout); } + if (cap && file == NULL) { + ret = capinfo_for_dom(uri, dominfo, &capsinfo); + if (ret == 0) { + printf("Unable to get capsinfo\n"); + return 3; + } else { + print_capabilities(capsinfo, stdout); + + fprintf(stdout, "-- Default Arch is: %s\n", + get_default_arch(capsinfo,NULL)); + fprintf(stdout, "-- Default Machine is: %s\n", + get_default_machine(capsinfo,NULL,NULL,NULL)); + fprintf(stdout, "-- Default Emulator is: %s\n", + get_default_emulator(capsinfo,NULL,NULL,NULL)); + fprintf(stdout, "-- Default Machine for domain type=kvm : %s\n", + get_default_machine(capsinfo,NULL,NULL,"kvm")); + fprintf(stdout, "-- Default Emulator for domain type=kvm : %s\n", + get_default_emulator(capsinfo,NULL,NULL,"kvm")); + + fprintf(stdout, "\n-- Default Domain Search for: \n" + "guest type=hvm - guest arch=* - guest domain type=kvm\n"); + capgdinfo = findDomainInfo(capsinfo, "hvm", NULL, "kvm"); + print_cap_domain_info(capgdinfo, stdout); + + fprintf(stdout, "-- Default Domain Search for: \n" + "guest type=* - guest arch=* - guest domain type=*\n"); + capgdinfo = findDomainInfo(capsinfo, NULL, NULL, NULL); + print_cap_domain_info(capgdinfo, stdout); + } + } else if (cap) { + printf("Need a data source (--domain) to get default capabilities\n"); + return 4; + } + return 0; } -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 15 14:48:19 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 15 Aug 2013 16:48:19 +0200 Subject: [Libvirt-cim] [PATCH 1/4] VSSD: Add properties for arch and machine In-Reply-To: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1376578102-2909-2-git-send-email-mihajlov@linux.vnet.ibm.com> For architectures like s390 the machine type is relevant for the proper guest construction. We add the necessary properties to the schema and the C structures and the necessary code for CIM-to-libvirt mapping. While doing this I noticed that the union fields in os_info were set by means of XML parsing which doesn't take into account that certain fields are depending on the virtualization type. This could lead both to memory overwrites and memory leaks. Fixed by using temporary variables and type-based setting of fields Signed-off-by: Viktor Mihajlovski --- libxkutil/device_parsing.c | 85 ++++++++++++++++++++++------- libxkutil/device_parsing.h | 2 + libxkutil/xmlgen.c | 6 ++ schema/VSSD.mof | 6 ++ src/Virt_VSSD.c | 9 +++ src/Virt_VirtualSystemManagementService.c | 14 +++++ 6 files changed, 101 insertions(+), 21 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index ffdf682..df7a87a 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1077,23 +1077,41 @@ int parse_fq_devid(const char *devid, char **host, char **device) return 1; } +static void cleanup_bootlist(char **blist, unsigned blist_ct) +{ + while (blist_ct > 0) { + free(blist[--blist_ct]); + } + free(blist); +} + static int parse_os(struct domain *dominfo, xmlNode *os) { xmlNode *child; char **blist = NULL; unsigned bl_size = 0; + char *arch = NULL; + char *machine = NULL; + char *kernel = NULL; + char *initrd = NULL; + char *cmdline = NULL; + char *loader = NULL; + char *boot = NULL; + char *init = NULL; for (child = os->children; child != NULL; child = child->next) { - if (XSTREQ(child->name, "type")) + if (XSTREQ(child->name, "type")) { STRPROP(dominfo, os_info.pv.type, child); - else if (XSTREQ(child->name, "kernel")) - STRPROP(dominfo, os_info.pv.kernel, child); + arch = get_attr_value(child, "arch"); + machine = get_attr_value(child, "machine"); + } else if (XSTREQ(child->name, "kernel")) + kernel = get_node_content(child); else if (XSTREQ(child->name, "initrd")) - STRPROP(dominfo, os_info.pv.initrd, child); + initrd = get_node_content(child); else if (XSTREQ(child->name, "cmdline")) - STRPROP(dominfo, os_info.pv.cmdline, child); + cmdline = get_node_content(child); else if (XSTREQ(child->name, "loader")) - STRPROP(dominfo, os_info.fv.loader, child); + loader = get_node_content(child); else if (XSTREQ(child->name, "boot")) { char **tmp_list = NULL; @@ -1111,7 +1129,7 @@ static int parse_os(struct domain *dominfo, xmlNode *os) blist[bl_size] = get_attr_value(child, "dev"); bl_size++; } else if (XSTREQ(child->name, "init")) - STRPROP(dominfo, os_info.lxc.init, child); + init = get_node_content(child); } if ((STREQC(dominfo->os_info.fv.type, "hvm")) && @@ -1128,17 +1146,45 @@ static int parse_os(struct domain *dominfo, xmlNode *os) else dominfo->type = -1; - if (STREQC(dominfo->os_info.fv.type, "hvm")) { + switch (dominfo->type) { + case DOMAIN_XENFV: + case DOMAIN_KVM: + case DOMAIN_QEMU: + dominfo->os_info.fv.loader = loader; + dominfo->os_info.fv.arch = arch; + dominfo->os_info.fv.machine = machine; dominfo->os_info.fv.bootlist_ct = bl_size; dominfo->os_info.fv.bootlist = blist; - } else { - int i; - - for (i = 0; i < bl_size; i++) - free(blist[i]); - free(blist); + loader = NULL; + arch = NULL; + machine = NULL; + blist = NULL; + bl_size = 0; + break; + case DOMAIN_XENPV: + dominfo->os_info.pv.kernel = kernel; + dominfo->os_info.pv.initrd = initrd; + dominfo->os_info.pv.cmdline = cmdline; + kernel = NULL; + initrd = NULL; + cmdline = NULL; + break; + case DOMAIN_LXC: + dominfo->os_info.lxc.init = init; + init = NULL; + break; + default: + break; } + free(arch); + free(machine); + free(kernel); + free(initrd); + free(cmdline); + free(boot); + free(init); + cleanup_bootlist(blist, bl_size); return 1; } @@ -1334,15 +1380,12 @@ void cleanup_dominfo(struct domain **dominfo) free(dom->os_info.pv.cmdline); } else if ((dom->type == DOMAIN_XENFV) || (dom->type == DOMAIN_KVM) || (dom->type == DOMAIN_QEMU)) { - int i; - free(dom->os_info.fv.type); free(dom->os_info.fv.loader); - - for (i = 0; i < dom->os_info.fv.bootlist_ct; i++) { - free(dom->os_info.fv.bootlist[i]); - } - free(dom->os_info.fv.bootlist); + free(dom->os_info.fv.arch); + free(dom->os_info.fv.machine); + cleanup_bootlist(dom->os_info.fv.bootlist, + dom->os_info.fv.bootlist_ct); } else if (dom->type == DOMAIN_LXC) { free(dom->os_info.lxc.type); free(dom->os_info.lxc.init); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 2b6d3d1..379d48c 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -136,6 +136,8 @@ struct pv_os_info { struct fv_os_info { char *type; /* Should always be 'hvm' */ + char *arch; + char *machine; char *loader; unsigned bootlist_ct; char **bootlist; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 4287d42..f19830f 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -802,6 +802,12 @@ static char *_kvm_os_xml(xmlNodePtr root, struct domain *domain) if (tmp == NULL) return XML_ERROR; + if (os->arch) + xmlNewProp(tmp, BAD_CAST "arch", BAD_CAST os->arch); + + if (os->machine) + xmlNewProp(tmp, BAD_CAST "machine", BAD_CAST os->machine); + ret = _fv_bootlist_xml(root, os); if (ret == 0) return XML_ERROR; diff --git a/schema/VSSD.mof b/schema/VSSD.mof index 0359d67..2734d8e 100644 --- a/schema/VSSD.mof +++ b/schema/VSSD.mof @@ -48,6 +48,12 @@ class KVM_VirtualSystemSettingData : Virt_VirtualSystemSettingData [Description ("The emulator the guest should use during runtime.")] string Emulator; + [Description ("The guest's architecture.")] + string Arch; + + [Description ("The guest's machine type")] + string Machine; + }; [Description ( diff --git a/src/Virt_VSSD.c b/src/Virt_VSSD.c index 3363b38..67e56aa 100644 --- a/src/Virt_VSSD.c +++ b/src/Virt_VSSD.c @@ -121,6 +121,15 @@ static CMPIStatus _set_fv_prop(const CMPIBroker *broker, goto out; } + if (dominfo->os_info.fv.arch != NULL) + CMSetProperty(inst, "Arch", + (CMPIValue *)dominfo->os_info.fv.arch, + CMPI_chars); + + if (dominfo->os_info.fv.machine != NULL) + CMSetProperty(inst, "Machine", + (CMPIValue *)dominfo->os_info.fv.machine, + CMPI_chars); out: return s; } diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 8ced2d6..3df878f 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -543,6 +543,20 @@ static int fv_vssd_to_domain(CMPIInstance *inst, if (!fv_set_emulator(domain, val)) return 0; + free(domain->os_info.fv.arch); + ret = cu_get_str_prop(inst, "Arch", &val); + if (ret == CMPI_RC_OK) + domain->os_info.fv.arch = strdup(val); + else + domain->os_info.fv.arch = NULL; + + free(domain->os_info.fv.machine); + ret = cu_get_str_prop(inst, "Machine", &val); + if (ret == CMPI_RC_OK) + domain->os_info.fv.machine = strdup(val); + else + domain->os_info.fv.machine = NULL; + return 1; } -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 15 14:48:22 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 15 Aug 2013 16:48:22 +0200 Subject: [Libvirt-cim] [PATCH 4/4] VSSM: Set default values based on libvirt capabilities on DefineSystem calls In-Reply-To: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1376578102-2909-5-git-send-email-mihajlov@linux.vnet.ibm.com> From: Boris Fiuczynski In the DefineSystem call the architecture, machine and emulator for KVM are set to the hypervisor-specific default values if they did not get provided. This now allows architecture based decision making in the CIM providers to work for all platforms. Signed-off-by: Boris Fiuczynski Reviewed-by: Viktor Mihajlovski --- src/Virt_VirtualSystemManagementService.c | 130 ++++++++++++----------------- 1 file changed, 55 insertions(+), 75 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 3fad33b..b0d81d1 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -35,6 +35,7 @@ #include "cs_util.h" #include "misc_util.h" #include "device_parsing.h" +#include "capability_parsing.h" #include "xmlgen.h" #include @@ -388,59 +389,6 @@ static bool fv_set_emulator(struct domain *domain, return true; } -static bool system_has_kvm(const char *pfx) -{ - CMPIStatus s; - virConnectPtr conn = NULL; - char *caps = NULL; - bool disable_kvm = get_disable_kvm(); - xmlDocPtr doc = NULL; - xmlNodePtr node = NULL; - int len; - bool kvm = false; - - /* sometimes disable KVM to avoid problem in nested KVM */ - if (disable_kvm) { - CU_DEBUG("Enter disable kvm mode!"); - goto out; - } - - conn = connect_by_classname(_BROKER, pfx, &s); - if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { - goto out; - } - - caps = virConnectGetCapabilities(conn); - if (caps != NULL) { - len = strlen(caps) + 1; - - doc = xmlParseMemory(caps, len); - if (doc == NULL) { - CU_DEBUG("xmlParseMemory() call failed!"); - goto out; - } - - node = xmlDocGetRootElement(doc); - if (node == NULL) { - CU_DEBUG("xmlDocGetRootElement() call failed!"); - goto out; - } - - if (has_kvm_domain_type(node)) { - CU_DEBUG("The system support kvm!"); - kvm = true; - } - } - -out: - free(caps); - free(doc); - - virConnectClose(conn); - - return kvm; -} - static int bootord_vssd_to_domain(CMPIInstance *inst, struct domain *domain) { @@ -511,13 +459,17 @@ static int bootord_vssd_to_domain(CMPIInstance *inst, static int fv_vssd_to_domain(CMPIInstance *inst, struct domain *domain, - const char *pfx) + const char *pfx, + virConnectPtr conn) { int ret; const char *val; + struct capabilities *capsinfo = NULL; + + get_capabilities(conn, &capsinfo); if (STREQC(pfx, "KVM")) { - if (system_has_kvm(pfx)) + if (use_kvm(capsinfo)) domain->type = DOMAIN_KVM; else domain->type = DOMAIN_QEMU; @@ -532,30 +484,49 @@ static int fv_vssd_to_domain(CMPIInstance *inst, if (ret != 1) return 0; - ret = cu_get_str_prop(inst, "Emulator", &val); - if (ret != CMPI_RC_OK) - val = NULL; - else if (disk_type_from_file(val) == DISK_UNKNOWN) { - CU_DEBUG("Emulator path does not exist: %s", val); - return 0; - } - - if (!fv_set_emulator(domain, val)) - return 0; - free(domain->os_info.fv.arch); ret = cu_get_str_prop(inst, "Arch", &val); - if (ret == CMPI_RC_OK) + if (ret != CMPI_RC_OK) { + if (capsinfo != NULL) { /* set default */ + val = get_default_arch(capsinfo, "hvm"); + CU_DEBUG("Set Arch to default: %s", val); + } else + val = NULL; + } + if (val != NULL) domain->os_info.fv.arch = strdup(val); - else - domain->os_info.fv.arch = NULL; free(domain->os_info.fv.machine); ret = cu_get_str_prop(inst, "Machine", &val); - if (ret == CMPI_RC_OK) + if (ret != CMPI_RC_OK) { + if (capsinfo != NULL) { /* set default */ + val = get_default_machine(capsinfo, "hvm", + domain->os_info.fv.arch, + "kvm"); + CU_DEBUG("Set Machine to default: %s", val); + } else + val = NULL; + } + if (val != NULL) domain->os_info.fv.machine = strdup(val); - else - domain->os_info.fv.machine = NULL; + + ret = cu_get_str_prop(inst, "Emulator", &val); + if (ret != CMPI_RC_OK) { + if (capsinfo != NULL) { /* set default */ + val = get_default_emulator(capsinfo, "hvm", + domain->os_info.fv.arch, + "kvm"); + CU_DEBUG("Set Emulator to default: %s", val); + } else + val = NULL; + } + if (val != NULL && disk_type_from_file(val) == DISK_UNKNOWN) { + CU_DEBUG("Emulator path does not exist: %s", val); + return 0; + } + + if (!fv_set_emulator(domain, val)) + return 0; return 1; } @@ -663,6 +634,8 @@ static int vssd_to_domain(CMPIInstance *inst, bool bool_val; bool fullvirt; CMPIObjectPath *opathp = NULL; + virConnectPtr conn = NULL; + CMPIStatus s = { CMPI_RC_OK, NULL }; opathp = CMGetObjectPath(inst, NULL); @@ -748,9 +721,16 @@ static int vssd_to_domain(CMPIInstance *inst, } } - if (fullvirt || STREQC(pfx, "KVM")) - ret = fv_vssd_to_domain(inst, domain, pfx); - else if (STREQC(pfx, "Xen")) + if (fullvirt || STREQC(pfx, "KVM")) { + conn = connect_by_classname(_BROKER, cn, &s); + if (conn == NULL || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("libvirt connection failed"); + ret = 0; + goto out; + } + ret = fv_vssd_to_domain(inst, domain, pfx, conn); + virConnectClose(conn); + } else if (STREQC(pfx, "Xen")) ret = xenpv_vssd_to_domain(inst, domain); else if (STREQC(pfx, "LXC")) ret = lxc_vssd_to_domain(inst, domain); -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 15 14:48:20 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 15 Aug 2013 16:48:20 +0200 Subject: [Libvirt-cim] [PATCH 2/4] S390: Avoid the generation of default input and graphics In-Reply-To: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1376578102-2909-3-git-send-email-mihajlov@linux.vnet.ibm.com> KVM guests for the s390 architecture do not support graphics and input devices. We use the os_info.fv.arch property to recognize such guests and skip the default device generation for those. Signed-off-by: Viktor Mihajlovski --- src/Virt_VirtualSystemManagementService.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 3df878f..3fad33b 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -583,6 +583,12 @@ static bool default_graphics_device(struct domain *domain) if (domain->type == DOMAIN_LXC) return true; + if (domain->type == DOMAIN_KVM && + domain->os_info.fv.arch != NULL && + (XSTREQ(domain->os_info.fv.arch, "s390") || + XSTREQ(domain->os_info.fv.arch, "s390x" ))) + return true; + free(domain->dev_graphics); domain->dev_graphics = calloc(1, sizeof(*domain->dev_graphics)); if (domain->dev_graphics == NULL) { @@ -605,6 +611,12 @@ static bool default_input_device(struct domain *domain) if (domain->type == DOMAIN_LXC) return true; + if (domain->type == DOMAIN_KVM && + domain->os_info.fv.arch != NULL && + (XSTREQ(domain->os_info.fv.arch, "s390") || + XSTREQ(domain->os_info.fv.arch, "s390x" ))) + return true; + free(domain->dev_input); domain->dev_input = calloc(1, sizeof(*domain->dev_input)); if (domain->dev_input == NULL) { -- 1.7.9.5 From xiawenc at linux.vnet.ibm.com Mon Aug 19 03:31:24 2013 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Mon, 19 Aug 2013 11:31:24 +0800 Subject: [Libvirt-cim] [PATCH 1/4] VSSD: Add properties for arch and machine In-Reply-To: <1376578102-2909-2-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-2-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5211918C.4090404@linux.vnet.ibm.com> ? 2013-8-15 22:48, Viktor Mihajlovski ??: > For architectures like s390 the machine type is relevant for > the proper guest construction. We add the necessary properties > to the schema and the C structures and the necessary code > for CIM-to-libvirt mapping. > > While doing this I noticed that the union fields in os_info > were set by means of XML parsing which doesn't take into account > that certain fields are depending on the virtualization type. I think this is a issue. Could u split this patch into two: 1 consider virt type for os_info, bugfix. 2 add xml-domain-VSSD mapping for properties machine and arch. Thus will make commit history clear and easier to review. > This could lead both to memory overwrites and memory leaks. > Fixed by using temporary variables and type-based setting of fields > > Signed-off-by: Viktor Mihajlovski > --- > libxkutil/device_parsing.c | 85 ++++++++++++++++++++++------- > libxkutil/device_parsing.h | 2 + > libxkutil/xmlgen.c | 6 ++ > schema/VSSD.mof | 6 ++ > src/Virt_VSSD.c | 9 +++ > src/Virt_VirtualSystemManagementService.c | 14 +++++ > 6 files changed, 101 insertions(+), 21 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index ffdf682..df7a87a 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -1077,23 +1077,41 @@ int parse_fq_devid(const char *devid, char **host, char **device) > return 1; > } > > +static void cleanup_bootlist(char **blist, unsigned blist_ct) > +{ > + while (blist_ct > 0) { > + free(blist[--blist_ct]); > + } > + free(blist); > +} > + > static int parse_os(struct domain *dominfo, xmlNode *os) > { > xmlNode *child; > char **blist = NULL; > unsigned bl_size = 0; > + char *arch = NULL; > + char *machine = NULL; > + char *kernel = NULL; > + char *initrd = NULL; > + char *cmdline = NULL; > + char *loader = NULL; > + char *boot = NULL; > + char *init = NULL; > > for (child = os->children; child != NULL; child = child->next) { > - if (XSTREQ(child->name, "type")) > + if (XSTREQ(child->name, "type")) { > STRPROP(dominfo, os_info.pv.type, child); > - else if (XSTREQ(child->name, "kernel")) > - STRPROP(dominfo, os_info.pv.kernel, child); > + arch = get_attr_value(child, "arch"); > + machine = get_attr_value(child, "machine"); > + } else if (XSTREQ(child->name, "kernel")) > + kernel = get_node_content(child); > else if (XSTREQ(child->name, "initrd")) > - STRPROP(dominfo, os_info.pv.initrd, child); > + initrd = get_node_content(child); > else if (XSTREQ(child->name, "cmdline")) > - STRPROP(dominfo, os_info.pv.cmdline, child); > + cmdline = get_node_content(child); > else if (XSTREQ(child->name, "loader")) > - STRPROP(dominfo, os_info.fv.loader, child); > + loader = get_node_content(child); > else if (XSTREQ(child->name, "boot")) { > char **tmp_list = NULL; > > @@ -1111,7 +1129,7 @@ static int parse_os(struct domain *dominfo, xmlNode *os) > blist[bl_size] = get_attr_value(child, "dev"); > bl_size++; > } else if (XSTREQ(child->name, "init")) > - STRPROP(dominfo, os_info.lxc.init, child); > + init = get_node_content(child); > } > > if ((STREQC(dominfo->os_info.fv.type, "hvm")) && > @@ -1128,17 +1146,45 @@ static int parse_os(struct domain *dominfo, xmlNode *os) > else > dominfo->type = -1; > > - if (STREQC(dominfo->os_info.fv.type, "hvm")) { > + switch (dominfo->type) { > + case DOMAIN_XENFV: > + case DOMAIN_KVM: > + case DOMAIN_QEMU: > + dominfo->os_info.fv.loader = loader; > + dominfo->os_info.fv.arch = arch; > + dominfo->os_info.fv.machine = machine; "machine = NULL;" is missing? Otherwise dominfo->os_info.fv.machine point to a value which is freed later. > dominfo->os_info.fv.bootlist_ct = bl_size; > dominfo->os_info.fv.bootlist = blist; > - } else { > - int i; > - > - for (i = 0; i < bl_size; i++) > - free(blist[i]); > - free(blist); > + loader = NULL; > + arch = NULL; > + machine = NULL; > + blist = NULL; > + bl_size = 0; > + break; > + case DOMAIN_XENPV: > + dominfo->os_info.pv.kernel = kernel; > + dominfo->os_info.pv.initrd = initrd; > + dominfo->os_info.pv.cmdline = cmdline; > + kernel = NULL; > + initrd = NULL; > + cmdline = NULL; > + break; > + case DOMAIN_LXC: > + dominfo->os_info.lxc.init = init; > + init = NULL; > + break; > + default: > + break; > } > > + free(arch); > + free(machine); > + free(kernel); > + free(initrd); > + free(cmdline); > + free(boot); > + free(init); > + cleanup_bootlist(blist, bl_size); > return 1; > } > > @@ -1334,15 +1380,12 @@ void cleanup_dominfo(struct domain **dominfo) > free(dom->os_info.pv.cmdline); > } else if ((dom->type == DOMAIN_XENFV) || > (dom->type == DOMAIN_KVM) || (dom->type == DOMAIN_QEMU)) { > - int i; > - > free(dom->os_info.fv.type); > free(dom->os_info.fv.loader); > - > - for (i = 0; i < dom->os_info.fv.bootlist_ct; i++) { > - free(dom->os_info.fv.bootlist[i]); > - } > - free(dom->os_info.fv.bootlist); > + free(dom->os_info.fv.arch); > + free(dom->os_info.fv.machine); > + cleanup_bootlist(dom->os_info.fv.bootlist, > + dom->os_info.fv.bootlist_ct); > } else if (dom->type == DOMAIN_LXC) { > free(dom->os_info.lxc.type); > free(dom->os_info.lxc.init); > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 2b6d3d1..379d48c 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -136,6 +136,8 @@ struct pv_os_info { > > struct fv_os_info { > char *type; /* Should always be 'hvm' */ > + char *arch; > + char *machine; > char *loader; > unsigned bootlist_ct; > char **bootlist; > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 4287d42..f19830f 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -802,6 +802,12 @@ static char *_kvm_os_xml(xmlNodePtr root, struct domain *domain) > if (tmp == NULL) > return XML_ERROR; > > + if (os->arch) > + xmlNewProp(tmp, BAD_CAST "arch", BAD_CAST os->arch); > + > + if (os->machine) > + xmlNewProp(tmp, BAD_CAST "machine", BAD_CAST os->machine); > + > ret = _fv_bootlist_xml(root, os); > if (ret == 0) > return XML_ERROR; > diff --git a/schema/VSSD.mof b/schema/VSSD.mof > index 0359d67..2734d8e 100644 > --- a/schema/VSSD.mof > +++ b/schema/VSSD.mof > @@ -48,6 +48,12 @@ class KVM_VirtualSystemSettingData : Virt_VirtualSystemSettingData > [Description ("The emulator the guest should use during runtime.")] > string Emulator; > > + [Description ("The guest's architecture.")] > + string Arch; > + > + [Description ("The guest's machine type")] > + string Machine; > + > }; I haven't check DMTF docs, but wonder if there are existing DMTF file point out where this property should belong. If no, I think put it in VSSD is OK. > > [Description ( > diff --git a/src/Virt_VSSD.c b/src/Virt_VSSD.c > index 3363b38..67e56aa 100644 > --- a/src/Virt_VSSD.c > +++ b/src/Virt_VSSD.c > @@ -121,6 +121,15 @@ static CMPIStatus _set_fv_prop(const CMPIBroker *broker, > goto out; > } > > + if (dominfo->os_info.fv.arch != NULL) > + CMSetProperty(inst, "Arch", > + (CMPIValue *)dominfo->os_info.fv.arch, > + CMPI_chars); > + > + if (dominfo->os_info.fv.machine != NULL) > + CMSetProperty(inst, "Machine", > + (CMPIValue *)dominfo->os_info.fv.machine, > + CMPI_chars); > out: > return s; > } > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 8ced2d6..3df878f 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -543,6 +543,20 @@ static int fv_vssd_to_domain(CMPIInstance *inst, > if (!fv_set_emulator(domain, val)) > return 0; > > + free(domain->os_info.fv.arch); > + ret = cu_get_str_prop(inst, "Arch", &val); > + if (ret == CMPI_RC_OK) > + domain->os_info.fv.arch = strdup(val); > + else > + domain->os_info.fv.arch = NULL; > + > + free(domain->os_info.fv.machine); > + ret = cu_get_str_prop(inst, "Machine", &val); > + if (ret == CMPI_RC_OK) > + domain->os_info.fv.machine = strdup(val); > + else > + domain->os_info.fv.machine = NULL; > + > return 1; > } > -- Best Regards Wenchao Xia From xiawenc at linux.vnet.ibm.com Mon Aug 19 08:35:18 2013 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Mon, 19 Aug 2013 16:35:18 +0800 Subject: [Libvirt-cim] [PATCH 1/4] VSSD: Add properties for arch and machine In-Reply-To: <5211918C.4090404@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-2-git-send-email-mihajlov@linux.vnet.ibm.com> <5211918C.4090404@linux.vnet.ibm.com> Message-ID: <5211D8C6.1070706@linux.vnet.ibm.com> ? 2013-8-19 11:31, Wenchao Xia ??: > ? 2013-8-15 22:48, Viktor Mihajlovski ??: >> For architectures like s390 the machine type is relevant for >> the proper guest construction. We add the necessary properties >> to the schema and the C structures and the necessary code >> for CIM-to-libvirt mapping. >> >> While doing this I noticed that the union fields in os_info >> were set by means of XML parsing which doesn't take into account >> that certain fields are depending on the virtualization type. > I think this is a issue. Could u split this patch into two: > 1 consider virt type for os_info, bugfix. > 2 add xml-domain-VSSD mapping for properties machine and arch. > > Thus will make commit history clear and easier to review. > >> This could lead both to memory overwrites and memory leaks. >> Fixed by using temporary variables and type-based setting of fields >> >> Signed-off-by: Viktor Mihajlovski >> --- >> libxkutil/device_parsing.c | 85 >> ++++++++++++++++++++++------- >> libxkutil/device_parsing.h | 2 + >> libxkutil/xmlgen.c | 6 ++ >> schema/VSSD.mof | 6 ++ >> src/Virt_VSSD.c | 9 +++ >> src/Virt_VirtualSystemManagementService.c | 14 +++++ >> 6 files changed, 101 insertions(+), 21 deletions(-) >> >> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c >> index ffdf682..df7a87a 100644 >> --- a/libxkutil/device_parsing.c >> +++ b/libxkutil/device_parsing.c >> @@ -1077,23 +1077,41 @@ int parse_fq_devid(const char *devid, char >> **host, char **device) >> return 1; >> } >> >> +static void cleanup_bootlist(char **blist, unsigned blist_ct) >> +{ >> + while (blist_ct > 0) { >> + free(blist[--blist_ct]); >> + } >> + free(blist); >> +} >> + >> static int parse_os(struct domain *dominfo, xmlNode *os) >> { >> xmlNode *child; >> char **blist = NULL; >> unsigned bl_size = 0; >> + char *arch = NULL; >> + char *machine = NULL; >> + char *kernel = NULL; >> + char *initrd = NULL; >> + char *cmdline = NULL; >> + char *loader = NULL; >> + char *boot = NULL; >> + char *init = NULL; >> >> for (child = os->children; child != NULL; child = >> child->next) { >> - if (XSTREQ(child->name, "type")) >> + if (XSTREQ(child->name, "type")) { >> STRPROP(dominfo, os_info.pv.type, child); >> - else if (XSTREQ(child->name, "kernel")) >> - STRPROP(dominfo, os_info.pv.kernel, child); >> + arch = get_attr_value(child, "arch"); >> + machine = get_attr_value(child, "machine"); >> + } else if (XSTREQ(child->name, "kernel")) >> + kernel = get_node_content(child); >> else if (XSTREQ(child->name, "initrd")) >> - STRPROP(dominfo, os_info.pv.initrd, child); >> + initrd = get_node_content(child); >> else if (XSTREQ(child->name, "cmdline")) >> - STRPROP(dominfo, os_info.pv.cmdline, child); >> + cmdline = get_node_content(child); >> else if (XSTREQ(child->name, "loader")) >> - STRPROP(dominfo, os_info.fv.loader, child); >> + loader = get_node_content(child); >> else if (XSTREQ(child->name, "boot")) { >> char **tmp_list = NULL; >> >> @@ -1111,7 +1129,7 @@ static int parse_os(struct domain *dominfo, >> xmlNode *os) >> blist[bl_size] = get_attr_value(child, "dev"); >> bl_size++; >> } else if (XSTREQ(child->name, "init")) >> - STRPROP(dominfo, os_info.lxc.init, child); >> + init = get_node_content(child); >> } >> >> if ((STREQC(dominfo->os_info.fv.type, "hvm")) && >> @@ -1128,17 +1146,45 @@ static int parse_os(struct domain *dominfo, >> xmlNode *os) >> else >> dominfo->type = -1; >> >> - if (STREQC(dominfo->os_info.fv.type, "hvm")) { >> + switch (dominfo->type) { >> + case DOMAIN_XENFV: >> + case DOMAIN_KVM: >> + case DOMAIN_QEMU: >> + dominfo->os_info.fv.loader = loader; >> + dominfo->os_info.fv.arch = arch; >> + dominfo->os_info.fv.machine = machine; > "machine = NULL;" is missing? Otherwise dominfo->os_info.fv.machine > point to a value which is freed later. > Sorry I missed that it is in the following lines, so this is not a problem. >> dominfo->os_info.fv.bootlist_ct = bl_size; >> dominfo->os_info.fv.bootlist = blist; >> - } else { >> - int i; >> - >> - for (i = 0; i < bl_size; i++) >> - free(blist[i]); >> - free(blist); >> + loader = NULL; >> + arch = NULL; >> + machine = NULL; >> + blist = NULL; >> + bl_size = 0; >> + break; >> + case DOMAIN_XENPV: >> + dominfo->os_info.pv.kernel = kernel; >> + dominfo->os_info.pv.initrd = initrd; >> + dominfo->os_info.pv.cmdline = cmdline; >> + kernel = NULL; >> + initrd = NULL; >> + cmdline = NULL; >> + break; >> + case DOMAIN_LXC: >> + dominfo->os_info.lxc.init = init; >> + init = NULL; >> + break; >> + default: >> + break; >> } >> >> + free(arch); >> + free(machine); >> + free(kernel); >> + free(initrd); >> + free(cmdline); >> + free(boot); >> + free(init); >> + cleanup_bootlist(blist, bl_size); >> return 1; >> } >> >> @@ -1334,15 +1380,12 @@ void cleanup_dominfo(struct domain **dominfo) >> free(dom->os_info.pv.cmdline); >> } else if ((dom->type == DOMAIN_XENFV) || >> (dom->type == DOMAIN_KVM) || (dom->type == >> DOMAIN_QEMU)) { >> - int i; >> - >> free(dom->os_info.fv.type); >> free(dom->os_info.fv.loader); >> - >> - for (i = 0; i < dom->os_info.fv.bootlist_ct; i++) { >> - free(dom->os_info.fv.bootlist[i]); >> - } >> - free(dom->os_info.fv.bootlist); >> + free(dom->os_info.fv.arch); >> + free(dom->os_info.fv.machine); >> + cleanup_bootlist(dom->os_info.fv.bootlist, >> + dom->os_info.fv.bootlist_ct); >> } else if (dom->type == DOMAIN_LXC) { >> free(dom->os_info.lxc.type); >> free(dom->os_info.lxc.init); >> diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h >> index 2b6d3d1..379d48c 100644 >> --- a/libxkutil/device_parsing.h >> +++ b/libxkutil/device_parsing.h >> @@ -136,6 +136,8 @@ struct pv_os_info { >> >> struct fv_os_info { >> char *type; /* Should always be 'hvm' */ >> + char *arch; >> + char *machine; >> char *loader; >> unsigned bootlist_ct; >> char **bootlist; >> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >> index 4287d42..f19830f 100644 >> --- a/libxkutil/xmlgen.c >> +++ b/libxkutil/xmlgen.c >> @@ -802,6 +802,12 @@ static char *_kvm_os_xml(xmlNodePtr root, struct >> domain *domain) >> if (tmp == NULL) >> return XML_ERROR; >> >> + if (os->arch) >> + xmlNewProp(tmp, BAD_CAST "arch", BAD_CAST os->arch); >> + >> + if (os->machine) >> + xmlNewProp(tmp, BAD_CAST "machine", BAD_CAST >> os->machine); >> + >> ret = _fv_bootlist_xml(root, os); >> if (ret == 0) >> return XML_ERROR; >> diff --git a/schema/VSSD.mof b/schema/VSSD.mof >> index 0359d67..2734d8e 100644 >> --- a/schema/VSSD.mof >> +++ b/schema/VSSD.mof >> @@ -48,6 +48,12 @@ class KVM_VirtualSystemSettingData : >> Virt_VirtualSystemSettingData >> [Description ("The emulator the guest should use during runtime.")] >> string Emulator; >> >> + [Description ("The guest's architecture.")] >> + string Arch; >> + >> + [Description ("The guest's machine type")] >> + string Machine; >> + >> }; > I haven't check DMTF docs, but wonder if there are existing DMTF file > point out where this property should belong. If no, I think put it > in VSSD is OK. > >> >> [Description ( >> diff --git a/src/Virt_VSSD.c b/src/Virt_VSSD.c >> index 3363b38..67e56aa 100644 >> --- a/src/Virt_VSSD.c >> +++ b/src/Virt_VSSD.c >> @@ -121,6 +121,15 @@ static CMPIStatus _set_fv_prop(const CMPIBroker >> *broker, >> goto out; >> } >> >> + if (dominfo->os_info.fv.arch != NULL) >> + CMSetProperty(inst, "Arch", >> + (CMPIValue *)dominfo->os_info.fv.arch, >> + CMPI_chars); >> + >> + if (dominfo->os_info.fv.machine != NULL) >> + CMSetProperty(inst, "Machine", >> + (CMPIValue *)dominfo->os_info.fv.machine, >> + CMPI_chars); >> out: >> return s; >> } >> diff --git a/src/Virt_VirtualSystemManagementService.c >> b/src/Virt_VirtualSystemManagementService.c >> index 8ced2d6..3df878f 100644 >> --- a/src/Virt_VirtualSystemManagementService.c >> +++ b/src/Virt_VirtualSystemManagementService.c >> @@ -543,6 +543,20 @@ static int fv_vssd_to_domain(CMPIInstance *inst, >> if (!fv_set_emulator(domain, val)) >> return 0; >> >> + free(domain->os_info.fv.arch); >> + ret = cu_get_str_prop(inst, "Arch", &val); >> + if (ret == CMPI_RC_OK) >> + domain->os_info.fv.arch = strdup(val); >> + else >> + domain->os_info.fv.arch = NULL; >> + >> + free(domain->os_info.fv.machine); >> + ret = cu_get_str_prop(inst, "Machine", &val); >> + if (ret == CMPI_RC_OK) >> + domain->os_info.fv.machine = strdup(val); >> + else >> + domain->os_info.fv.machine = NULL; >> + >> return 1; >> } >> > > -- Best Regards Wenchao Xia From gesaint at linux.vnet.ibm.com Mon Aug 19 09:11:10 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 19 Aug 2013 17:11:10 +0800 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory Message-ID: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> dumpCore tag in the is not supported by libvirt-cim and it will be dropped during updating any element in the xml definition of a domain. This patch keep the tag all the time. Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 28 +++++++++++++++++++++++++++- libxkutil/device_parsing.h | 3 +++ libxkutil/xmlgen.c | 9 +++++++++ 3 files changed, 39 insertions(+), 1 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 7900e06..96db532 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -605,8 +605,17 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) if (XSTREQ(node->name, "currentMemory")) sscanf(content, "%" PRIu64, &mdev->size); - else if (XSTREQ(node->name, "memory")) + else if (XSTREQ(node->name, "memory")) { sscanf(content, "%" PRIu64, &mdev->maxsize); + content = get_attr_value(node, "dumpCore"); + if (XSTREQ(content, "on")) { + mdev->dumpCore = MEM_DUMP_CORE_ON; + } else if (XSTREQ(content, "off")) { + mdev->dumpCore = MEM_DUMP_CORE_OFF; + } else { + mdev->dumpCore = MEM_DUMP_CORE_NOT_SET; + } + } free(content); @@ -968,6 +977,7 @@ static int _get_mem_device(const char *xml, struct virt_device **list) struct virt_device *mdevs = NULL; struct virt_device *mdev = NULL; int ret; + bool mem_dump_core_set = false; ret = parse_devices(xml, &mdevs, CIM_RES_TYPE_MEM); if (ret <= 0) @@ -987,10 +997,26 @@ static int _get_mem_device(const char *xml, struct virt_device **list) mdevs[1].dev.mem.size); mdev->dev.mem.maxsize = MAX(mdevs[0].dev.mem.maxsize, mdevs[1].dev.mem.maxsize); + /* libvirt dumpCore tag always belong to memory xml node, but + * here we may have two mdev for memory node and currentMemory + * node. So pick up one value. + */ + if (mdevs[0].dev.mem.dumpCore != MEM_DUMP_CORE_NOT_SET) { + mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore; + mem_dump_core_set = true; + } else if (mdevs[1].dev.mem.dumpCore != + MEM_DUMP_CORE_NOT_SET) { + if (mem_dump_core_set) { + CU_DEBUG("WARN: libvirt set memory core dump in" + "two nodes!"); + } + mdev->dev.mem.dumpCore = mdevs[1].dev.mem.dumpCore; + } } else { mdev->dev.mem.size = MAX(mdevs[0].dev.mem.size, mdevs[0].dev.mem.maxsize); mdev->dev.mem.maxsize = mdev->dev.mem.size; + mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore; } mdev->type = CIM_RES_TYPE_MEM; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 2b6d3d1..979b792 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -75,6 +75,9 @@ struct net_device { struct mem_device { uint64_t size; uint64_t maxsize; + enum { MEM_DUMP_CORE_NOT_SET, + MEM_DUMP_CORE_ON, + MEM_DUMP_CORE_OFF } dumpCore; }; struct vcpu_device { diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 4287d42..30e9a5e 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -498,6 +498,15 @@ static const char *mem_xml(xmlNodePtr root, struct domain *dominfo) BAD_CAST string); free(string); + + if (tmp == NULL) + return XML_ERROR; + if (mem->dumpCore == MEM_DUMP_CORE_ON) { + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "on"); + } else if (mem->dumpCore == MEM_DUMP_CORE_OFF) { + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "off"); + } + out: if (tmp == NULL) return XML_ERROR; -- 1.7.1 From mihajlov at linux.vnet.ibm.com Mon Aug 19 10:47:01 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Mon, 19 Aug 2013 12:47:01 +0200 Subject: [Libvirt-cim] [PATCH 1/4] VSSD: Add properties for arch and machine In-Reply-To: <5211D8C6.1070706@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-2-git-send-email-mihajlov@linux.vnet.ibm.com> <5211918C.4090404@linux.vnet.ibm.com> <5211D8C6.1070706@linux.vnet.ibm.com> Message-ID: <5211F7A5.2000901@linux.vnet.ibm.com> On 08/19/2013 10:35 AM, Wenchao Xia wrote: > ? 2013-8-19 11:31, Wenchao Xia ??: >> ? 2013-8-15 22:48, Viktor Mihajlovski ??: >>> For architectures like s390 the machine type is relevant for >>> the proper guest construction. We add the necessary properties >>> to the schema and the C structures and the necessary code >>> for CIM-to-libvirt mapping. >>> >>> While doing this I noticed that the union fields in os_info >>> were set by means of XML parsing which doesn't take into account >>> that certain fields are depending on the virtualization type. >> I think this is a issue. Could u split this patch into two: >> 1 consider virt type for os_info, bugfix. >> 2 add xml-domain-VSSD mapping for properties machine and arch. >> >> Thus will make commit history clear and easier to review. reasonable enough, I will send out a split version once I get feedback for the other patches. >> [...] >> I haven't check DMTF docs, but wonder if there are existing DMTF file >> point out where this property should belong. If no, I think put it >> in VSSD is OK. It wouldn't logically fit into a RASD since it defines an intrinsic property of the guest, not of an associated resource, so VSSD is the right place for the property. -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Mon Aug 19 11:34:50 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Mon, 19 Aug 2013 13:34:50 +0200 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <521202DA.3010307@linux.vnet.ibm.com> On 08/19/2013 11:11 AM, Xu Wang wrote: > dumpCore tag in the is not supported by libvirt-cim and > it will be dropped during updating any element in the xml definition > of a domain. This patch keep the tag all the time. > > Signed-off-by: Xu Wang > --- > libxkutil/device_parsing.c | 28 +++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 3 +++ > libxkutil/xmlgen.c | 9 +++++++++ > 3 files changed, 39 insertions(+), 1 deletions(-) > Hi, I am (again) writing to you only, as I am confused. With this patch you are obsoleting part of Thilo's patch to add support for the dumpCore tag. However, your version of the patch is not allowing to set the dumpCore, since it is lacking the RASD extension. How do you want to proceed, do you want us to rebase Thilo's patch on top of your version, once it gets accepted upstream? If so, that's fine with me and I would post a review comment on the libvirt-cim mailing list. If you plan to submit a patch for RASD support of dumpCore on your, please let me know, in which case we can spare us the effort of rebasing Thilo's patch. -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From xiawenc at linux.vnet.ibm.com Tue Aug 20 01:56:11 2013 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Tue, 20 Aug 2013 09:56:11 +0800 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5212CCBB.5060202@linux.vnet.ibm.com> ? 2013-8-19 17:11, Xu Wang ??: > dumpCore tag in the is not supported by libvirt-cim and > it will be dropped during updating any element in the xml definition > of a domain. This patch keep the tag all the time. > > Signed-off-by: Xu Wang > --- > libxkutil/device_parsing.c | 28 +++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 3 +++ > libxkutil/xmlgen.c | 9 +++++++++ > 3 files changed, 39 insertions(+), 1 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index 7900e06..96db532 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -605,8 +605,17 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) > > if (XSTREQ(node->name, "currentMemory")) > sscanf(content, "%" PRIu64, &mdev->size); > - else if (XSTREQ(node->name, "memory")) > + else if (XSTREQ(node->name, "memory")) { > sscanf(content, "%" PRIu64, &mdev->maxsize); > + content = get_attr_value(node, "dumpCore"); > + if (XSTREQ(content, "on")) { > + mdev->dumpCore = MEM_DUMP_CORE_ON; > + } else if (XSTREQ(content, "off")) { > + mdev->dumpCore = MEM_DUMP_CORE_OFF; > + } else { > + mdev->dumpCore = MEM_DUMP_CORE_NOT_SET; > + } > + } > > free(content); > > @@ -968,6 +977,7 @@ static int _get_mem_device(const char *xml, struct virt_device **list) > struct virt_device *mdevs = NULL; > struct virt_device *mdev = NULL; > int ret; > + bool mem_dump_core_set = false; > > ret = parse_devices(xml, &mdevs, CIM_RES_TYPE_MEM); > if (ret <= 0) > @@ -987,10 +997,26 @@ static int _get_mem_device(const char *xml, struct virt_device **list) > mdevs[1].dev.mem.size); > mdev->dev.mem.maxsize = MAX(mdevs[0].dev.mem.maxsize, > mdevs[1].dev.mem.maxsize); > + /* libvirt dumpCore tag always belong to memory xml node, but > + * here we may have two mdev for memory node and currentMemory > + * node. So pick up one value. > + */ > + if (mdevs[0].dev.mem.dumpCore != MEM_DUMP_CORE_NOT_SET) { > + mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore; > + mem_dump_core_set = true; > + } else if (mdevs[1].dev.mem.dumpCore != > + MEM_DUMP_CORE_NOT_SET) { > + if (mem_dump_core_set) { > + CU_DEBUG("WARN: libvirt set memory core dump in" > + "two nodes!"); > + } > + mdev->dev.mem.dumpCore = mdevs[1].dev.mem.dumpCore; > + } > } else { > mdev->dev.mem.size = MAX(mdevs[0].dev.mem.size, > mdevs[0].dev.mem.maxsize); > mdev->dev.mem.maxsize = mdev->dev.mem.size; > + mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore; > } > > mdev->type = CIM_RES_TYPE_MEM; > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 2b6d3d1..979b792 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -75,6 +75,9 @@ struct net_device { > struct mem_device { > uint64_t size; > uint64_t maxsize; > + enum { MEM_DUMP_CORE_NOT_SET, > + MEM_DUMP_CORE_ON, > + MEM_DUMP_CORE_OFF } dumpCore; > }; > > struct vcpu_device { > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 4287d42..30e9a5e 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -498,6 +498,15 @@ static const char *mem_xml(xmlNodePtr root, struct domain *dominfo) > BAD_CAST string); > > free(string); > + > + if (tmp == NULL) > + return XML_ERROR; No checking with tmp is a bugfix, so better to fix it in another patch. And also, better to add documents in commit message that: "This patch just add mapping between libvirt xml and struct mem_device, it make sure this tag will not be changed in cim call". About the code, no other issues found. Reviewed-by: Wenchao Xia > + if (mem->dumpCore == MEM_DUMP_CORE_ON) { > + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "on"); > + } else if (mem->dumpCore == MEM_DUMP_CORE_OFF) { > + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "off"); > + } > + > out: > if (tmp == NULL) > return XML_ERROR; > -- Best Regards Wenchao Xia From gesaint at linux.vnet.ibm.com Tue Aug 20 01:56:58 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Tue, 20 Aug 2013 09:56:58 +0800 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <521202DA.3010307@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> <521202DA.3010307@linux.vnet.ibm.com> Message-ID: <5212CCEA.3000909@linux.vnet.ibm.com> ? 2013-08-19 19:34, Viktor Mihajlovski ??: > On 08/19/2013 11:11 AM, Xu Wang wrote: >> dumpCore tag in the is not supported by libvirt-cim and >> it will be dropped during updating any element in the xml definition >> of a domain. This patch keep the tag all the time. >> >> Signed-off-by: Xu Wang >> --- >> libxkutil/device_parsing.c | 28 +++++++++++++++++++++++++++- >> libxkutil/device_parsing.h | 3 +++ >> libxkutil/xmlgen.c | 9 +++++++++ >> 3 files changed, 39 insertions(+), 1 deletions(-) >> > > Hi, > > I am (again) writing to you only, as I am confused. With this > patch you are obsoleting part of Thilo's patch to add support > for the dumpCore tag. However, your version of the patch is > not allowing to set the dumpCore, since it is lacking the RASD > extension. > How do you want to proceed, do you want us to rebase Thilo's > patch on top of your version, once it gets accepted upstream? > If so, that's fine with me and I would post a review comment on > the libvirt-cim mailing list. If you plan to submit a patch for > RASD support of dumpCore on your, please let me know, in which case > we can spare us the effort of rebasing Thilo's patch. > Hi, Ralf makes me submit this patch into mail list. But it may conflicts with some others. If you want the Thilo's patch merged into upstream please submit it ASAP. Because Ralf want that property supported by libvirt-cim IN THIS WEEK. If you merged that patch, please drop this one. Thanks, Xu Wang From xiawenc at linux.vnet.ibm.com Tue Aug 20 02:25:07 2013 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Tue, 20 Aug 2013 10:25:07 +0800 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <5212CCEA.3000909@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> <521202DA.3010307@linux.vnet.ibm.com> <5212CCEA.3000909@linux.vnet.ibm.com> Message-ID: <5212D383.9010800@linux.vnet.ibm.com> ? 2013-8-20 9:56, Xu Wang ??: > ? 2013-08-19 19:34, Viktor Mihajlovski ??: >> On 08/19/2013 11:11 AM, Xu Wang wrote: >>> dumpCore tag in the is not supported by libvirt-cim and >>> it will be dropped during updating any element in the xml definition >>> of a domain. This patch keep the tag all the time. >>> >>> Signed-off-by: Xu Wang >>> --- >>> libxkutil/device_parsing.c | 28 +++++++++++++++++++++++++++- >>> libxkutil/device_parsing.h | 3 +++ >>> libxkutil/xmlgen.c | 9 +++++++++ >>> 3 files changed, 39 insertions(+), 1 deletions(-) >>> >> >> Hi, >> >> I am (again) writing to you only, as I am confused. With this >> patch you are obsoleting part of Thilo's patch to add support >> for the dumpCore tag. However, your version of the patch is >> not allowing to set the dumpCore, since it is lacking the RASD >> extension. >> How do you want to proceed, do you want us to rebase Thilo's >> patch on top of your version, once it gets accepted upstream? >> If so, that's fine with me and I would post a review comment on >> the libvirt-cim mailing list. If you plan to submit a patch for >> RASD support of dumpCore on your, please let me know, in which case >> we can spare us the effort of rebasing Thilo's patch. >> > Hi, > Ralf makes me submit this patch into mail list. But it may conflicts > with some others. If you > want the Thilo's patch merged into upstream please submit it ASAP. Because > Ralf want that property supported by libvirt-cim IN THIS WEEK. If you > merged that patch, > please drop this one. > > Thanks, > Xu Wang > Hi, we can discuss this kind of issue in internal email box. Let's use public email list for patch discuss, and hear from other developer's opinion. > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wenchao Xia From mihajlov at linux.vnet.ibm.com Tue Aug 20 06:44:24 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Tue, 20 Aug 2013 08:44:24 +0200 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <5212CCBB.5060202@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> <5212CCBB.5060202@linux.vnet.ibm.com> Message-ID: <52131048.5050707@linux.vnet.ibm.com> On 08/20/2013 03:56 AM, Wenchao Xia wrote: [...] >> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >> index 4287d42..30e9a5e 100644 >> --- a/libxkutil/xmlgen.c >> +++ b/libxkutil/xmlgen.c >> @@ -498,6 +498,15 @@ static const char *mem_xml(xmlNodePtr root, >> struct domain *dominfo) >> BAD_CAST string); >> >> free(string); >> + >> + if (tmp == NULL) >> + return XML_ERROR; > No checking with tmp is a bugfix, so better to fix it in another > patch. actually, this *is* related to the patch changes, because before the patch, tmp == NULL was handled in the out: section, without this check we would run into a problem doing the xmlNewProp calls. So you should keep this as is. BTW: the result of xmlNewProp isn't checked, but then the libxkutil code doesn't seem to be consistent in this matter... -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From xiawenc at linux.vnet.ibm.com Tue Aug 20 11:06:52 2013 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Tue, 20 Aug 2013 19:06:52 +0800 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <52131048.5050707@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> <5212CCBB.5060202@linux.vnet.ibm.com> <52131048.5050707@linux.vnet.ibm.com> Message-ID: <52134DCC.8070408@linux.vnet.ibm.com> ? 2013-8-20 14:44, Viktor Mihajlovski ??: > On 08/20/2013 03:56 AM, Wenchao Xia wrote: > [...] >>> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >>> index 4287d42..30e9a5e 100644 >>> --- a/libxkutil/xmlgen.c >>> +++ b/libxkutil/xmlgen.c >>> @@ -498,6 +498,15 @@ static const char *mem_xml(xmlNodePtr root, >>> struct domain *dominfo) >>> BAD_CAST string); >>> >>> free(string); >>> + >>> + if (tmp == NULL) >>> + return XML_ERROR; >> No checking with tmp is a bugfix, so better to fix it in another >> patch. > actually, this *is* related to the patch changes, because before the > patch, tmp == NULL was handled in the out: section, without this > check we would run into a problem doing the xmlNewProp calls. > So you should keep this as is. > BTW: the result of xmlNewProp isn't checked, but then the libxkutil code > doesn't seem to be consistent in this matter... > You are right, I missed there are following lines, this check make sure no new bug introduced. -- Best Regards Wenchao Xia From jtomko at redhat.com Wed Aug 21 14:19:23 2013 From: jtomko at redhat.com (=?UTF-8?q?J=C3=A1n=20Tomko?=) Date: Wed, 21 Aug 2013 16:19:23 +0200 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers Message-ID: Older libvirt-cim might've installed these in the sblim-sfcb repository, causing errors when calling sfcbrepos on libvirt-cim update. --- libvirt-cim.spec.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index a027246..cd399b1 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -84,6 +84,13 @@ rm -fr $RPM_BUILD_ROOT -n @CIM_VIRT_NS@ \ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true +# Remove open-pegasus-specific providers installed in sfcb repository +# by older libvirt-cim packages +%{_datadir}/%{name}/provider-register.sh -d -t sfcb \ + -n root/PG_InterOp \ + -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true + + %post /sbin/ldconfig -- 1.8.1.5 From jferlan at redhat.com Thu Aug 22 00:14:37 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 21 Aug 2013 20:14:37 -0400 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers In-Reply-To: References: Message-ID: <521557ED.6080904@redhat.com> On 08/21/2013 10:19 AM, J?n Tomko wrote: > +# Remove open-pegasus-specific providers installed in sfcb repository > +# by older libvirt-cim packages > +%{_datadir}/%{name}/provider-register.sh -d -t sfcb \ > + -n root/PG_InterOp \ > + -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true > + > + I'm no expert in this matter, but I wonder if those would ever have been installed. Does anyone have a RHEL6 environment with sfcb only where pginterop was installed? I guess I see no harm in this, but I have less experience with the sfcb environment... Anyone else have comments/thoughts? John From jmiao at redhat.com Thu Aug 22 02:10:34 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Wed, 21 Aug 2013 22:10:34 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers In-Reply-To: <521557ED.6080904@redhat.com> References: <521557ED.6080904@redhat.com> Message-ID: <1993601568.2881912.1377137434437.JavaMail.root@redhat.com> ----- Original Message ----- > I'm no expert in this matter, but I wonder if those would ever have been > installed. Does anyone have a RHEL6 environment with sfcb only where > pginterop was installed? I have RHEL6.5 with sfcb installed. > > > I guess I see no harm in this, but I have less experience with the sfcb > environment... Anyone else have comments/thoughts? I remember I have verified a bug https://bugzilla.redhat.com/show_bug.cgi?id=859122 > > John > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > From jtomko at redhat.com Thu Aug 22 08:39:10 2013 From: jtomko at redhat.com (=?ISO-8859-1?Q?J=E1n_Tomko?=) Date: Thu, 22 Aug 2013 10:39:10 +0200 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers In-Reply-To: <521557ED.6080904@redhat.com> References: <521557ED.6080904@redhat.com> Message-ID: <5215CE2E.8090206@redhat.com> On 08/22/2013 02:14 AM, John Ferlan wrote: > On 08/21/2013 10:19 AM, J?n Tomko wrote: >> +# Remove open-pegasus-specific providers installed in sfcb repository >> +# by older libvirt-cim packages >> +%{_datadir}/%{name}/provider-register.sh -d -t sfcb \ >> + -n root/PG_InterOp \ >> + -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true >> + >> + > > I'm no expert in this matter, but I wonder if those would ever have been > installed. Does anyone have a RHEL6 environment with sfcb only where > pginterop was installed? > Yes, if you install libvirt-cim-0.6.1-4.el6 (which is the version in RHEL6.4), PG_InterOp would get installed as well. Since upstream commit 07adabc, the providers registered on installation are only unregistered on uninstall, not update. Commit 19ffef8 only fixed this for uninstall -> install, where PG_InterOp gets unregistered by the old package (without this commit) and the new package (with the commit) doesn't register it. On upgrade, the old package leaves it behind. Jan From jtomko at redhat.com Thu Aug 22 08:39:11 2013 From: jtomko at redhat.com (=?ISO-8859-1?Q?J=E1n_Tomko?=) Date: Thu, 22 Aug 2013 10:39:11 +0200 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers In-Reply-To: <1993601568.2881912.1377137434437.JavaMail.root@redhat.com> References: <521557ED.6080904@redhat.com> <1993601568.2881912.1377137434437.JavaMail.root@redhat.com> Message-ID: <5215CE2F.60305@redhat.com> On 08/22/2013 04:10 AM, Jincheng Miao wrote: > ----- Original Message ----- >> I'm no expert in this matter, but I wonder if those would ever have been >> installed. Does anyone have a RHEL6 environment with sfcb only where >> pginterop was installed? > > I have RHEL6.5 with sfcb installed. > Which hasn't been released yet. >> >> >> I guess I see no harm in this, but I have less experience with the sfcb >> environment... Anyone else have comments/thoughts? > > I remember I have verified a bug https://bugzilla.redhat.com/show_bug.cgi?id=859122 > I prefer not to post private bugzilla links to public lists, as they result in a rather annoying big red "access denied" message to most of the people. Jan From jmiao at redhat.com Thu Aug 22 09:15:16 2013 From: jmiao at redhat.com (Jincheng Miao) Date: Thu, 22 Aug 2013 05:15:16 -0400 (EDT) Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers In-Reply-To: <5215CE2E.8090206@redhat.com> References: <521557ED.6080904@redhat.com> <5215CE2E.8090206@redhat.com> Message-ID: <1772562026.3181228.1377162916280.JavaMail.root@redhat.com> ----- Original Message ----- > Yes, if you install libvirt-cim-0.6.1-4.el6 (which is the version in > RHEL6.4), > PG_InterOp would get installed as well. > > Since upstream commit 07adabc, the providers registered on installation are > only unregistered on uninstall, not update. > > Commit 19ffef8 only fixed this for uninstall -> install, where PG_InterOp > gets > unregistered by the old package (without this commit) and the new package > (with the commit) doesn't register it. > > On upgrade, the old package leaves it behind. yes, confirm. some verification steps: 1. for old package it can clean the PG_InterOp as we seen # rpm -ivh libvirt-cim-0.6.1-4.el6_4.1.x86_64.rpm Preparing... ########################################### [100%] 1:libvirt-cim ########################################### [100%] [ OK ] down CIM server: [ OK ] Starting up CIM server: [ OK ] # ls /var/lib/sfcb/registration/repository/root/ cimv2 interop PG_InterOp virt # rpm -e libvirt-cim Deleting registered classes in libvirt-cim. Deleting registered classes in libvirt-cim. # ls /var/lib/sfcb/registration/repository/root/ cimv2 interop 2. for upgrade libvirt-cim # rpm -ivh libvirt-cim-0.6.1-4.el6_4.1.x86_64.rpm Preparing... ########################################### [100%] 1:libvirt-cim ########################################### [100%] [ OK ] down CIM server: [ OK ] Starting up CIM server: [ OK ] # ls /var/lib/sfcb/registration/repository/root/ cimv2 interop PG_InterOp virt # sfcbrepos -f -c /usr/share/mof/cimv2.22.0/ logger not started*** Repository error for /var/lib/sfcb/registration/repository//root/pg_interop/qualifiers could not write qualifier Association backend error has occured writing classSchemas Failed compiling the MOF files. # rpm -Uvh libvirt-cim-0.6.1-7.el6.x86_64.rpm Preparing... ########################################### [100%] 1:libvirt-cim ########################################### [100%] [ OK ] down CIM server: [ OK ] Starting up CIM server: [ OK ] # ls /var/lib/sfcb/registration/repository/root/ cimv2 interop PG_InterOp virt # sfcbrepos -f -c /usr/share/mof/cimv2.22.0/ logger not started*** Repository error for /var/lib/sfcb/registration/repository//root/pg_interop/qualifiers could not write qualifier Association backend error has occured writing classSchemas Failed compiling the MOF files. # rpm -e libvirt-cim Deleting registered classes in libvirt-cim. Deleting registered classes in libvirt-cim. # ls /var/lib/sfcb/registration/repository/root/ cimv2 interop PG_InterOp Here we can still find PG_InterOp. So we should keep the clean script for PG_InterOp. From jferlan at redhat.com Thu Aug 22 11:02:04 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 22 Aug 2013 07:02:04 -0400 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers In-Reply-To: References: Message-ID: <5215EFAC.9020008@redhat.com> On 08/21/2013 10:19 AM, J?n Tomko wrote: > Older libvirt-cim might've installed these in the sblim-sfcb > repository, causing errors when calling sfcbrepos on libvirt-cim update. > --- > libvirt-cim.spec.in | 7 +++++++ > 1 file changed, 7 insertions(+) > ACK John From jtomko at redhat.com Thu Aug 22 11:38:41 2013 From: jtomko at redhat.com (=?ISO-8859-1?Q?J=E1n_Tomko?=) Date: Thu, 22 Aug 2013 13:38:41 +0200 Subject: [Libvirt-cim] [PATCH] libvirt-cim.spec.in: Uninstall open-pegasus-specific providers In-Reply-To: <5215EFAC.9020008@redhat.com> References: <5215EFAC.9020008@redhat.com> Message-ID: <5215F841.3050006@redhat.com> On 08/22/2013 01:02 PM, John Ferlan wrote: > On 08/21/2013 10:19 AM, J?n Tomko wrote: >> Older libvirt-cim might've installed these in the sblim-sfcb >> repository, causing errors when calling sfcbrepos on libvirt-cim update. >> --- >> libvirt-cim.spec.in | 7 +++++++ >> 1 file changed, 7 insertions(+) >> > > ACK > > John > Thank you, pushed now. Jan From xiawenc at linux.vnet.ibm.com Fri Aug 23 02:55:52 2013 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Fri, 23 Aug 2013 10:55:52 +0800 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <52134DCC.8070408@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> <5212CCBB.5060202@linux.vnet.ibm.com> <52131048.5050707@linux.vnet.ibm.com> <52134DCC.8070408@linux.vnet.ibm.com> Message-ID: <5216CF38.8000406@linux.vnet.ibm.com> ? 2013-8-20 19:06, Wenchao Xia ??: > ? 2013-8-20 14:44, Viktor Mihajlovski ??: >> On 08/20/2013 03:56 AM, Wenchao Xia wrote: >> [...] >>>> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >>>> index 4287d42..30e9a5e 100644 >>>> --- a/libxkutil/xmlgen.c >>>> +++ b/libxkutil/xmlgen.c >>>> @@ -498,6 +498,15 @@ static const char *mem_xml(xmlNodePtr root, >>>> struct domain *dominfo) >>>> BAD_CAST string); >>>> >>>> free(string); >>>> + >>>> + if (tmp == NULL) >>>> + return XML_ERROR; >>> No checking with tmp is a bugfix, so better to fix it in another >>> patch. >> actually, this *is* related to the patch changes, because before the >> patch, tmp == NULL was handled in the out: section, without this >> check we would run into a problem doing the xmlNewProp calls. >> So you should keep this as is. >> BTW: the result of xmlNewProp isn't checked, but then the libxkutil code >> doesn't seem to be consistent in this matter... >> > You are right, I missed there are following lines, this check make > sure no new bug introduced. > Hi, John The code of this patch seems OK to me, do you have a time to review it? If you found no new issue, can you push this patch upstream? -- Best Regards Wenchao Xia From jferlan at redhat.com Fri Aug 23 19:33:34 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 15:33:34 -0400 Subject: [Libvirt-cim] [PATCH V3] Add dumpCore tag support to memory In-Reply-To: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1376903470-4996-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5217B90E.8050507@redhat.com> On 08/19/2013 05:11 AM, Xu Wang wrote: > dumpCore tag in the is not supported by libvirt-cim and > it will be dropped during updating any element in the xml definition > of a domain. This patch keep the tag all the time. > I had put off reviewing/testing because I wasn't sure what the outcome of the initial responses on the list were going to be... Anyway, couple of thoughts 1. Is there test for this? That is - is there a way to ensure the right things are done based on the setting of this? Is there a specific cimtest that could be added? How would one know this setting has taken ahold? 2. Did you run cimtest with this applied? In an environment without dumpCore? Mine failed rather spectacularly today with just this applied to top of the tree. In fact "ComputerSystem" and "01_enum.py" returns: ComputerSystem - 01_enum.py: FAIL ERROR - Provider does not report system `f18', but virsh does ERROR - Provider does not report system `if18lcl', but virsh does ERROR - Provider does not report system `if18net', but virsh does ERROR - Provider does not report system `if18nopool', but virsh does ERROR - Provider does not report system `rh64', but virsh does ERROR - Provider does not report system `rh70-alpha3', but virsh does CIM_ERR_FAILED: Lost connection with cimprovagt "libvirt-cim". I did a bit of debugging though and believe I know the cause (see below). > Signed-off-by: Xu Wang > --- > libxkutil/device_parsing.c | 28 +++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 3 +++ > libxkutil/xmlgen.c | 9 +++++++++ > 3 files changed, 39 insertions(+), 1 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index 7900e06..96db532 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -605,8 +605,17 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) > > if (XSTREQ(node->name, "currentMemory")) > sscanf(content, "%" PRIu64, &mdev->size); > - else if (XSTREQ(node->name, "memory")) > + else if (XSTREQ(node->name, "memory")) { > sscanf(content, "%" PRIu64, &mdev->maxsize); > + content = get_attr_value(node, "dumpCore"); if (content == NULL), then this fails rather spectacularly I squashed the following and pushed (after running cimtest successfully and checking for coverity issues) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index fc4338b..542e4e9 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -609,9 +609,9 @@ static int parse_mem_device(xmlNode *node, struct virt_devic else if (XSTREQ(node->name, "memory")) { sscanf(content, "%" PRIu64, &mdev->maxsize); content = get_attr_value(node, "dumpCore"); - if (XSTREQ(content, "on")) { + if (content && XSTREQ(content, "on")) { mdev->dumpCore = MEM_DUMP_CORE_ON; - } else if (XSTREQ(content, "off")) { + } else if (content && XSTREQ(content, "off")) { mdev->dumpCore = MEM_DUMP_CORE_OFF; } else { mdev->dumpCore = MEM_DUMP_CORE_NOT_SET; John > + if (XSTREQ(content, "on")) { > + mdev->dumpCore = MEM_DUMP_CORE_ON; > + } else if (XSTREQ(content, "off")) { > + mdev->dumpCore = MEM_DUMP_CORE_OFF; > + } else { > + mdev->dumpCore = MEM_DUMP_CORE_NOT_SET; > + } > + } > > free(content); > > @@ -968,6 +977,7 @@ static int _get_mem_device(const char *xml, struct virt_device **list) > struct virt_device *mdevs = NULL; > struct virt_device *mdev = NULL; > int ret; > + bool mem_dump_core_set = false; > > ret = parse_devices(xml, &mdevs, CIM_RES_TYPE_MEM); > if (ret <= 0) > @@ -987,10 +997,26 @@ static int _get_mem_device(const char *xml, struct virt_device **list) > mdevs[1].dev.mem.size); > mdev->dev.mem.maxsize = MAX(mdevs[0].dev.mem.maxsize, > mdevs[1].dev.mem.maxsize); > + /* libvirt dumpCore tag always belong to memory xml node, but > + * here we may have two mdev for memory node and currentMemory > + * node. So pick up one value. > + */ > + if (mdevs[0].dev.mem.dumpCore != MEM_DUMP_CORE_NOT_SET) { > + mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore; > + mem_dump_core_set = true; > + } else if (mdevs[1].dev.mem.dumpCore != > + MEM_DUMP_CORE_NOT_SET) { > + if (mem_dump_core_set) { > + CU_DEBUG("WARN: libvirt set memory core dump in" > + "two nodes!"); > + } > + mdev->dev.mem.dumpCore = mdevs[1].dev.mem.dumpCore; > + } > } else { > mdev->dev.mem.size = MAX(mdevs[0].dev.mem.size, > mdevs[0].dev.mem.maxsize); > mdev->dev.mem.maxsize = mdev->dev.mem.size; > + mdev->dev.mem.dumpCore = mdevs[0].dev.mem.dumpCore; > } > > mdev->type = CIM_RES_TYPE_MEM; > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 2b6d3d1..979b792 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -75,6 +75,9 @@ struct net_device { > struct mem_device { > uint64_t size; > uint64_t maxsize; > + enum { MEM_DUMP_CORE_NOT_SET, > + MEM_DUMP_CORE_ON, > + MEM_DUMP_CORE_OFF } dumpCore; > }; > > struct vcpu_device { > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 4287d42..30e9a5e 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -498,6 +498,15 @@ static const char *mem_xml(xmlNodePtr root, struct domain *dominfo) > BAD_CAST string); > > free(string); > + > + if (tmp == NULL) > + return XML_ERROR; > + if (mem->dumpCore == MEM_DUMP_CORE_ON) { > + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "on"); > + } else if (mem->dumpCore == MEM_DUMP_CORE_OFF) { > + xmlNewProp(tmp, BAD_CAST "dumpCore", BAD_CAST "off"); > + } > + > out: > if (tmp == NULL) > return XML_ERROR; > From jferlan at redhat.com Fri Aug 23 19:52:12 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 15:52:12 -0400 Subject: [Libvirt-cim] [PATCH 1/4] VSSD: Add properties for arch and machine In-Reply-To: <1376578102-2909-2-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-2-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5217BD6C.4040203@redhat.com> On 08/15/2013 10:48 AM, Viktor Mihajlovski wrote: > For architectures like s390 the machine type is relevant for > the proper guest construction. We add the necessary properties > to the schema and the C structures and the necessary code > for CIM-to-libvirt mapping. > > While doing this I noticed that the union fields in os_info > were set by means of XML parsing which doesn't take into account > that certain fields are depending on the virtualization type. > This could lead both to memory overwrites and memory leaks. > Fixed by using temporary variables and type-based setting of fields > > Signed-off-by: Viktor Mihajlovski > --- > libxkutil/device_parsing.c | 85 ++++++++++++++++++++++------- > libxkutil/device_parsing.h | 2 + > libxkutil/xmlgen.c | 6 ++ > schema/VSSD.mof | 6 ++ > src/Virt_VSSD.c | 9 +++ > src/Virt_VirtualSystemManagementService.c | 14 +++++ > 6 files changed, 101 insertions(+), 21 deletions(-) > ACK John (Working my way through the set now) From jferlan at redhat.com Fri Aug 23 20:16:29 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 16:16:29 -0400 Subject: [Libvirt-cim] [PATCH 2/4] S390: Avoid the generation of default input and graphics In-Reply-To: <1376578102-2909-3-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-3-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5217C31D.7050503@redhat.com> On 08/15/2013 10:48 AM, Viktor Mihajlovski wrote: > KVM guests for the s390 architecture do not support graphics > and input devices. We use the os_info.fv.arch property to > recognize such guests and skip the default device generation > for those. > > Signed-off-by: Viktor Mihajlovski > --- > src/Virt_VirtualSystemManagementService.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > ACK John From jferlan at redhat.com Fri Aug 23 20:20:17 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 16:20:17 -0400 Subject: [Libvirt-cim] [PATCH 3/4] libxkutil: Provide easy access to the libvirt capabilities In-Reply-To: <1376578102-2909-4-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-4-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5217C401.4030009@redhat.com> On 08/15/2013 10:48 AM, Viktor Mihajlovski wrote: > From: Boris Fiuczynski > > Introspecting the libvirt capabilities and creating an internal capabilities > data structure. Methods are provided for retrieving default values regarding > architecture, machine and emulator for easy of use in the provider code. > > Further, xml_parse_test was extendend to display hypervisor capabilities > and defaults. > > Signed-off-by: Boris Fiuczynski > Signed-off-by: Viktor Mihajlovski > --- > libxkutil/Makefile.am | 2 + > libxkutil/capability_parsing.c | 462 ++++++++++++++++++++++++++++++++++++++++ > libxkutil/capability_parsing.h | 93 ++++++++ > libxkutil/xml_parse_test.c | 134 +++++++++++- > 4 files changed, 688 insertions(+), 3 deletions(-) > create mode 100644 libxkutil/capability_parsing.c > create mode 100644 libxkutil/capability_parsing.h > This seems to be missing something as my build fails (Fedora 19): CC xml_parse_test.o CCLD xml_parse_test xml_parse_test.o: In function `capinfo_for_dom': /path/to/libxkutil/xml_parse_test.c:263: undefined reference to `get_capabilities' xml_parse_test.o: In function `main': /path/to/libxkutil/xml_parse_test.c:431: undefined reference to `get_default_arch' /path/to/libvirt-cim.coverity/libxkutil/xml_parse_test.c:433: undefined reference to `get_default_machine' /path/to/libvirt-cim.coverity/libxkutil/xml_parse_test.c:435: undefined reference to `get_default_emulator' /path/to/libvirt-cim.coverity/libxkutil/xml_parse_test.c:437: undefined reference to `get_default_machine' /path/to/libvirt-cim.coverity/libxkutil/xml_parse_test.c:439: undefined reference to `get_default_emulator' /path/to/libvirt-cim.coverity/libxkutil/xml_parse_test.c:444: undefined reference to `findDomainInfo' /path/to/libvirt-cim.coverity/libxkutil/xml_parse_test.c:449: undefined reference to `findDomainInfo' collect2: error: ld returned 1 exit status make[2]: *** [xml_parse_test] Error 1 make[2]: Leaving directory `/path/to/libxkutil' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/path/to' make: *** [all] Error 2 I did not dig deeper into the code John > diff --git a/libxkutil/Makefile.am b/libxkutil/Makefile.am > index 8d436ad..dd7be55 100644 > --- a/libxkutil/Makefile.am > +++ b/libxkutil/Makefile.am > @@ -7,6 +7,7 @@ noinst_HEADERS = \ > cs_util.h \ > misc_util.h \ > device_parsing.h \ > + capability_parsing.h \ > xmlgen.h \ > infostore.h \ > pool_parsing.h \ > @@ -20,6 +21,7 @@ libxkutil_la_SOURCES = \ > cs_util_instance.c \ > misc_util.c \ > device_parsing.c \ > + capability_parsing.c \ > xmlgen.c \ > infostore.c \ > pool_parsing.c \ > diff --git a/libxkutil/capability_parsing.c b/libxkutil/capability_parsing.c > new file mode 100644 > index 0000000..2185584 > --- /dev/null > +++ b/libxkutil/capability_parsing.c > @@ -0,0 +1,462 @@ > +/* > + * Copyright IBM Corp. 2013 > + * > + * Authors: > + * Boris Fiuczynski > + * > + * 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 "misc_util.h" > +#include "capability_parsing.h" > +#include "xmlgen.h" > +#include "../src/svpc_types.h" > + > +static void cleanup_cap_machine(struct cap_machine *machine) > +{ > + if (machine == NULL) > + return; > + free(machine->name); > + free(machine->canonical_name); > +} > + > +void cleanup_cap_domain_info(struct cap_domain_info *cgdi) > +{ > + int i; > + if (cgdi == NULL) > + return; > + free(cgdi->emulator); > + free(cgdi->loader); > + for (i = 0; i < cgdi->num_machines; i++) > + cleanup_cap_machine(&cgdi->machines[i]); > + free(cgdi->machines); > +} > + > +static void cleanup_cap_domain(struct cap_domain *cgd) > +{ > + if (cgd == NULL) > + return; > + free(cgd->typestr); > + cleanup_cap_domain_info(&cgd->guest_domain_info); > +} > + > +static void cleanup_cap_arch(struct cap_arch *cga) > +{ > + int i; > + if (cga == NULL) > + return; > + free(cga->name); > + cleanup_cap_domain_info(&cga->default_domain_info); > + for (i = 0; i < cga->num_domains; i++) > + cleanup_cap_domain(&cga->domains[i]); > + free(cga->domains); > +} > + > +void cleanup_cap_guest(struct cap_guest *cg) > +{ > + if (cg == NULL) > + return; > + free(cg->ostype); > + cleanup_cap_arch(&cg->arch); > +} > + > +static void extend_cap_machines(struct cap_domain_info *cg_domaininfo, > + char *name, char *canonical_name) > +{ > + struct cap_machine *tmp_list = NULL; > + tmp_list = realloc(cg_domaininfo->machines, > + (cg_domaininfo->num_machines + 1) * > + sizeof(struct cap_machine)); > + > + if (tmp_list == NULL) { > + /* Nothing you can do. Just go on. */ > + CU_DEBUG("Could not alloc space for " > + "guest domain info list"); > + return; > + } > + cg_domaininfo->machines = tmp_list; > + > + struct cap_machine *cap_gm = > + &cg_domaininfo->machines[cg_domaininfo->num_machines]; > + cap_gm->name = name; > + cap_gm->canonical_name = canonical_name; > + cg_domaininfo->num_machines++; > +} > + > +static void parse_cap_domain_info(struct cap_domain_info *cg_domaininfo, > + xmlNode *domain_child_node) > +{ > + CU_DEBUG("Capabilities guest domain info element node: %s", > + domain_child_node->name); > + > + if (XSTREQ(domain_child_node->name, "emulator")) { > + cg_domaininfo->emulator = > + get_node_content(domain_child_node); > + } else if (XSTREQ(domain_child_node->name, "loader")) { > + cg_domaininfo->loader = > + get_node_content(domain_child_node); > + } else if (XSTREQ(domain_child_node->name, "machine")) { > + extend_cap_machines(cg_domaininfo, > + get_node_content(domain_child_node), > + get_attr_value(domain_child_node, > + "canonical")); > + } > +} > + > +static void parse_cap_domain(struct cap_domain *cg_domain, > + xmlNode *guest_dom) > +{ > + CU_DEBUG("Capabilities guest domain node: %s", guest_dom->name); > + > + xmlNode *child; > + > + cg_domain->typestr = get_attr_value(guest_dom, "type"); > + > + for (child = guest_dom->children; child != NULL; child = child->next) > + parse_cap_domain_info(&cg_domain->guest_domain_info, child); > +} > + > +static void parse_cap_arch(struct cap_arch *cg_archinfo, > + xmlNode *arch) > +{ > + CU_DEBUG("Capabilities arch node: %s", arch->name); > + > + xmlNode *child; > + > + cg_archinfo->name = get_attr_value(arch, "name"); > + > + for (child = arch->children; child != NULL; child = child->next) { > + if (XSTREQ(child->name, "wordsize")) { > + char *wordsize_str; > + unsigned int wordsize; > + wordsize_str = get_node_content(child); > + /* Default to 0 wordsize if garbage */ > + if (wordsize_str == NULL || > + sscanf(wordsize_str, "%i", &wordsize) != 1) > + wordsize = 0; > + free(wordsize_str); > + cg_archinfo->wordsize = wordsize; > + } else if (XSTREQ(child->name, "domain")) { > + struct cap_domain *tmp_list = NULL; > + tmp_list = realloc(cg_archinfo->domains, > + (cg_archinfo->num_domains + 1) * > + sizeof(struct cap_domain)); > + if (tmp_list == NULL) { > + /* Nothing you can do. Just go on. */ > + CU_DEBUG("Could not alloc space for " > + "guest domain"); > + continue; > + } > + memset(&tmp_list[cg_archinfo->num_domains], > + 0, sizeof(struct cap_domain)); > + cg_archinfo->domains = tmp_list; > + parse_cap_domain(&cg_archinfo-> > + domains[cg_archinfo->num_domains], > + child); > + cg_archinfo->num_domains++; > + } else { > + /* Check for the default domain child nodes */ > + parse_cap_domain_info(&cg_archinfo->default_domain_info, > + child); > + } > + } > +} > + > +static void parse_cap_guests(xmlNodeSet *nsv, struct cap_guest **cap_guests) > +{ > + xmlNode **nodes = nsv->nodeTab; > + xmlNode *child; > + int numGuestNodes = nsv->nodeNr; > + int i; > + > + for (i = 0; i < numGuestNodes; i++) { > + for (child = nodes[i]->children; child != NULL; > + child = child->next) { > + if (XSTREQ(child->name, "os_type")) { > + STRPROP(cap_guests[i], ostype, child); > + } else if (XSTREQ(child->name, "arch")) { > + parse_cap_arch(&cap_guests[i]->arch, child); > + } > + } > + } > +} > + > +static void compare_copy_domain_info_machines( > + struct cap_domain_info *def_gdomi, > + struct cap_domain_info *cap_gadomi) > +{ > + int i,j; > + int org_l = cap_gadomi->num_machines; > + char *cp_name = NULL; > + char *cp_canonical_name = NULL; > + bool found; > + > + for (i = 0; i < def_gdomi->num_machines; i++) { > + found = false; > + for (j = 0; j < org_l; j++) { > + if (STREQC(def_gdomi->machines[i].name, > + cap_gadomi->machines[j].name)) { > + found = true; > + continue; > + /* found match => check next default */ > + } > + } > + if (!found) { /* no match => insert default */ > + cp_name = NULL; > + cp_canonical_name = NULL; > + if (def_gdomi->machines[i].name != NULL) > + cp_name = strdup(def_gdomi->machines[i].name); > + if (def_gdomi->machines[i].canonical_name != NULL) > + cp_canonical_name = > + strdup(def_gdomi-> > + machines[i].canonical_name); > + > + extend_cap_machines(cap_gadomi, > + cp_name, > + cp_canonical_name); > + } > + } > +} > + > +static void extend_defaults_cap_guests(struct capabilities *caps) > +{ > + struct cap_arch *cap_garch; > + struct cap_domain_info *cap_gadomi; > + struct cap_domain_info *def_gdomi; > + int i,j; > + > + if (caps == NULL) > + return; > + > + for (i = 0; i < caps->num_guests; i++) { > + cap_garch = &caps->guests[i].arch; > + def_gdomi = &cap_garch->default_domain_info; > + > + for (j = 0; j < cap_garch->num_domains; j++) { > + /* compare guest_domain_info */ > + cap_gadomi = &cap_garch->domains[j].guest_domain_info; > + if (cap_gadomi->emulator == NULL && > + def_gdomi->emulator != NULL) > + cap_gadomi->emulator = > + strdup(def_gdomi->emulator); > + if (cap_gadomi->loader == NULL && > + def_gdomi->loader != NULL) > + cap_gadomi->loader = strdup(def_gdomi->loader); > + > + compare_copy_domain_info_machines(def_gdomi, > + cap_gadomi); > + } > + } > +} > + > +static int _get_cap_guests(const char *xml, struct capabilities *caps) > +{ > + int len; > + > + xmlDoc *xmldoc = NULL; > + xmlXPathContext *xpathctx = NULL; > + xmlXPathObject *xpathobj = NULL; > + const xmlChar *xpathstr = (xmlChar *)"//capabilities//guest"; > + xmlNodeSet *nsv; > + > + len = strlen(xml) + 1; > + > + if ((xmldoc = xmlParseMemory(xml, len)) == NULL) > + goto err; > + > + if ((xpathctx = xmlXPathNewContext(xmldoc)) == NULL) > + goto err; > + > + if ((xpathobj = xmlXPathEvalExpression(xpathstr, xpathctx)) == NULL) > + goto err; > + if (xmlXPathNodeSetIsEmpty(xpathobj->nodesetval)) { > + CU_DEBUG("No capabilities guest nodes found!"); > + goto err; > + } > + > + nsv = xpathobj->nodesetval; > + caps->guests = calloc(nsv->nodeNr, sizeof(struct cap_guest)); > + if (caps->guests == NULL) > + goto err; > + caps->num_guests = nsv->nodeNr; > + > + parse_cap_guests(nsv, &caps->guests); > + extend_defaults_cap_guests(caps); > + return 1; > + > + err: > + xmlXPathFreeObject(xpathobj); > + xmlXPathFreeContext(xpathctx); > + xmlFreeDoc(xmldoc); > + return 0; > +} > + > +int get_caps_from_xml(const char *xml, struct capabilities **caps) > +{ > + CU_DEBUG("In get_caps_from_xml"); > + > + *caps = calloc(1, sizeof(struct capabilities)); > + if (*caps == NULL) > + goto err; > + > + if (_get_cap_guests(xml, *caps) == 0) > + goto err; > + > + return 1; > + > + err: > + free(*caps); > + *caps = NULL; > + return 0; > +} > + > +int get_capabilities(virConnectPtr conn, struct capabilities **caps) > +{ > + char *caps_xml = NULL; > + int ret = 0; > + > + if (conn == NULL) { > + CU_DEBUG("Unable to connect to libvirt."); > + return 0; > + } > + > + caps_xml = virConnectGetCapabilities(conn); > + > + if (caps_xml == NULL) { > + CU_DEBUG("Unable to get capabilities xml."); > + return 0; > + } > + > + ret = get_caps_from_xml(caps_xml, caps); > + > + free(caps_xml); > + > + return ret; > +} > + > +struct cap_domain_info *findDomainInfo(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type) > +{ > + int i,j; > + struct cap_arch *ar; > + for (i = 0; i < caps->num_guests; i++) { > + if (os_type == NULL || > + STREQC(caps->guests[i].ostype, os_type)) { > + ar = &caps->guests[i].arch; > + if (arch == NULL || STREQC(ar->name,arch)) > + for (j = 0; j < ar->num_domains; j++) > + if (domain_type == NULL || > + STREQC(ar->domains[j].typestr, > + domain_type)) > + return &ar->domains[j]. > + guest_domain_info; > + } > + } > + return NULL; > +} > + > +char *get_default_arch(struct capabilities *caps, > + const char *os_type) > +{ > + char *ret = NULL; > + int i; > + > + if (caps != NULL) { > + if (os_type == NULL) { /* pick first guest */ > + if (caps->num_guests > 0) > + ret = caps->guests[0].arch.name; > + } else { /* search first matching guest */ > + for (i = 0; i < caps->num_guests; i++) > + if (STREQC(caps->guests[i].ostype, os_type)) { > + ret = caps->guests[i].arch.name; > + break; > + } > + } > + } > + return ret; > +} > + > +char *get_default_machine( > + struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type) > +{ > + char *ret = NULL; > + struct cap_domain_info *di; > + > + if (caps != NULL) { > + di = findDomainInfo(caps, os_type, arch, domain_type); > + if (di != NULL && di->num_machines > 0) > + ret = di->machines[0].canonical_name; > + } > + return ret; > +} > + > +char *get_default_emulator(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type) > +{ > + char *ret = NULL; > + struct cap_domain_info *di; > + > + if (caps != NULL) { > + di = findDomainInfo(caps, os_type, arch, domain_type); > + if (di != NULL) > + ret = di->emulator; > + } > + return ret; > +} > + > +bool use_kvm(struct capabilities *caps) { > + if (host_supports_kvm(caps) && !get_disable_kvm()) > + return true; > + else > + return false; > +} > + > +bool host_supports_kvm(struct capabilities *caps) > +{ > + bool kvm = false; > + if (caps != NULL) > + if (findDomainInfo(caps, NULL, NULL, "kvm") != NULL) > + kvm = true; > + return kvm; > +} > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ > diff --git a/libxkutil/capability_parsing.h b/libxkutil/capability_parsing.h > new file mode 100644 > index 0000000..13af510 > --- /dev/null > +++ b/libxkutil/capability_parsing.h > @@ -0,0 +1,93 @@ > +/* > + * Copyright IBM Corp. 2013 > + * > + * Authors: > + * Boris Fiuczynski > + * > + * 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 > + */ > +#ifndef __CAPABILITY_PARSING_H > +#define __CAPABILITY_PARSING_H > + > +#include > +#include > + > +struct cap_machine { > + char *name; > + char *canonical_name; > +}; > + > +struct cap_domain_info { > + char *emulator; > + char *loader; > + int num_machines; > + struct cap_machine *machines; > +}; > + > +struct cap_domain { > + char *typestr; > + struct cap_domain_info guest_domain_info; > +}; > + > +struct cap_arch { > + char *name; > + unsigned int wordsize; > + struct cap_domain_info default_domain_info; > + int num_domains; > + struct cap_domain *domains; > +}; > + > +struct cap_guest { > + char *ostype; > + struct cap_arch arch; > +}; > + > +struct capabilities { > + int num_guests; > + struct cap_guest *guests; > +}; > + > +int get_caps_from_xml(const char *xml, struct capabilities **caps); > +int get_capabilities(virConnectPtr conn, struct capabilities **caps); > +char *get_default_arch(struct capabilities *caps, > + const char *os_type); > +char *get_default_machine(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type); > +char *get_default_emulator(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type); > +struct cap_domain_info *findDomainInfo(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type); > +bool use_kvm(struct capabilities *caps); > +bool host_supports_kvm(struct capabilities *caps); > +void cleanup_cap_guest(struct cap_guest *cg); > +void cleanup_cap_domain_info(struct cap_domain_info *cgdi); > + > +#endif > + > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ > diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c > index 384593d..5c5f2df 100644 > --- a/libxkutil/xml_parse_test.c > +++ b/libxkutil/xml_parse_test.c > @@ -6,6 +6,7 @@ > #include > > #include "device_parsing.h" > +#include "capability_parsing.h" > #include "xmlgen.h" > > static void print_value(FILE *d, const char *name, const char *val) > @@ -183,6 +184,91 @@ static char *read_from_file(FILE *file) > return xml; > } > > +static void print_cap_domain_info(struct cap_domain_info *capgdiinfo, > + FILE *d) > +{ > + struct cap_machine capgminfo; > + int i; > + > + if (capgdiinfo==NULL) > + return; > + > + if (capgdiinfo->emulator!=NULL) > + print_value(d, " Emulator", capgdiinfo->emulator); > + if (capgdiinfo->loader!=NULL) > + print_value(d, " Loader", capgdiinfo->loader); > + for (i=0; inum_machines; i++) { > + capgminfo = capgdiinfo->machines[i]; > + fprintf(d, " Machine name : %-15s canonical name : %s\n", > + capgminfo.name, capgminfo.canonical_name); > + } > + fprintf(d, "\n"); > +} > + > +static void print_cap_domains(struct cap_arch caparchinfo, > + FILE *d) > +{ > + struct cap_domain capgdinfo; > + int i; > + for (i=0; i + capgdinfo = caparchinfo.domains[i]; > + print_value(d, " Type", capgdinfo.typestr); > + print_cap_domain_info(&capgdinfo.guest_domain_info, d); > + } > +} > + > +static void print_cap_arch(struct cap_arch caparchinfo, > + FILE *d) > +{ > + print_value(d, " Arch name", caparchinfo.name); > + fprintf(d, " Arch wordsize : %i\n", caparchinfo.wordsize); > + fprintf(d, "\n -- Default guest domain settings --\n"); > + print_cap_domain_info(&caparchinfo.default_domain_info, d); > + fprintf(d, " -- Guest domains (%i) --\n", caparchinfo.num_domains); > + print_cap_domains(caparchinfo, d); > +} > + > +static void print_cap_guest(struct cap_guest *capginfo, > + FILE *d) > +{ > + print_value(d, "Guest OS type", capginfo->ostype); > + print_cap_arch(capginfo->arch, d); > +} > + > +static void print_capabilities(struct capabilities *capsinfo, > + FILE *d) > +{ > + int i; > + fprintf(d, "\n### Capabilities ###\n"); > + fprintf(d, "-- Guest (%i) --\n", capsinfo->num_guests); > + for (i=0; inum_guests; i++) { > + print_cap_guest(&capsinfo->guests[i], d); > + } > +} > + > +static int capinfo_for_dom(const char *uri, > + struct domain *dominfo, > + struct capabilities **capsinfo) > +{ > + virConnectPtr conn = NULL; > + char *caps_xml = NULL; > + int ret = 0; > + > + conn = virConnectOpen(uri); > + if (conn == NULL) { > + printf("Unable to connect to libvirt\n"); > + goto out; > + } > + > + ret = get_capabilities(conn, capsinfo); > + > + out: > + free(caps_xml); > + virConnectClose(conn); > + > + return ret; > +} > + > static int dominfo_from_dom(const char *uri, > const char *domain, > struct domain **d) > @@ -246,12 +332,13 @@ static int dominfo_from_file(const char *fname, struct domain **d) > static void usage(void) > { > printf("xml_parse_test -f [FILE | -] [--xml]\n" > - "xml_parse_test -d domain [--uri URI] [--xml]\n" > + "xml_parse_test -d domain [--uri URI] [--xml] [--cap]\n" > "\n" > "-f,--file FILE Parse domain XML from file (or stdin if -)\n" > "-d,--domain DOM Display dominfo for a domain from libvirt\n" > "-u,--uri URI Connect to libvirt with URI\n" > "-x,--xml Dump generated XML instead of summary\n" > + "-c,--cap Display the libvirt default capability values for the specified domain\n" > "-h,--help Display this help message\n"); > } > > @@ -262,7 +349,10 @@ int main(int argc, char **argv) > char *uri = "xen"; > char *file = NULL; > bool xml = false; > + bool cap = false; > struct domain *dominfo = NULL; > + struct capabilities *capsinfo = NULL; > + struct cap_domain_info *capgdinfo = NULL; > int ret; > > static struct option lopts[] = { > @@ -270,13 +360,14 @@ int main(int argc, char **argv) > {"uri", 1, 0, 'u'}, > {"xml", 0, 0, 'x'}, > {"file", 1, 0, 'f'}, > + {"cap", 0, 0, 'c'}, > {"help", 0, 0, 'h'}, > {0, 0, 0, 0}}; > > while (1) { > int optidx = 0; > > - c = getopt_long(argc, argv, "d:u:f:xh", lopts, &optidx); > + c = getopt_long(argc, argv, "d:u:f:xch", lopts, &optidx); > if (c == -1) > break; > > @@ -297,11 +388,14 @@ int main(int argc, char **argv) > xml = true; > break; > > + case 'c': > + cap = true; > + break; > + > case '?': > case 'h': > usage(); > return c == '?'; > - > }; > } > > @@ -326,6 +420,40 @@ int main(int argc, char **argv) > print_devices(dominfo, stdout); > } > > + if (cap && file == NULL) { > + ret = capinfo_for_dom(uri, dominfo, &capsinfo); > + if (ret == 0) { > + printf("Unable to get capsinfo\n"); > + return 3; > + } else { > + print_capabilities(capsinfo, stdout); > + > + fprintf(stdout, "-- Default Arch is: %s\n", > + get_default_arch(capsinfo,NULL)); > + fprintf(stdout, "-- Default Machine is: %s\n", > + get_default_machine(capsinfo,NULL,NULL,NULL)); > + fprintf(stdout, "-- Default Emulator is: %s\n", > + get_default_emulator(capsinfo,NULL,NULL,NULL)); > + fprintf(stdout, "-- Default Machine for domain type=kvm : %s\n", > + get_default_machine(capsinfo,NULL,NULL,"kvm")); > + fprintf(stdout, "-- Default Emulator for domain type=kvm : %s\n", > + get_default_emulator(capsinfo,NULL,NULL,"kvm")); > + > + fprintf(stdout, "\n-- Default Domain Search for: \n" > + "guest type=hvm - guest arch=* - guest domain type=kvm\n"); > + capgdinfo = findDomainInfo(capsinfo, "hvm", NULL, "kvm"); > + print_cap_domain_info(capgdinfo, stdout); > + > + fprintf(stdout, "-- Default Domain Search for: \n" > + "guest type=* - guest arch=* - guest domain type=*\n"); > + capgdinfo = findDomainInfo(capsinfo, NULL, NULL, NULL); > + print_cap_domain_info(capgdinfo, stdout); > + } > + } else if (cap) { > + printf("Need a data source (--domain) to get default capabilities\n"); > + return 4; > + } > + > return 0; > } > > From jferlan at redhat.com Fri Aug 23 20:54:36 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 16:54:36 -0400 Subject: [Libvirt-cim] [PATCH 3/4] libxkutil: Provide easy access to the libvirt capabilities In-Reply-To: <1376578102-2909-4-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-4-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5217CC0C.2050708@redhat.com> On 08/15/2013 10:48 AM, Viktor Mihajlovski wrote: > From: Boris Fiuczynski > > Introspecting the libvirt capabilities and creating an internal capabilities > data structure. Methods are provided for retrieving default values regarding > architecture, machine and emulator for easy of use in the provider code. > > Further, xml_parse_test was extendend to display hypervisor capabilities > and defaults. > > Signed-off-by: Boris Fiuczynski > Signed-off-by: Viktor Mihajlovski > --- > libxkutil/Makefile.am | 2 + > libxkutil/capability_parsing.c | 462 ++++++++++++++++++++++++++++++++++++++++ > libxkutil/capability_parsing.h | 93 ++++++++ > libxkutil/xml_parse_test.c | 134 +++++++++++- > 4 files changed, 688 insertions(+), 3 deletions(-) > create mode 100644 libxkutil/capability_parsing.c > create mode 100644 libxkutil/capability_parsing.h > Fixed my build issue - had to run autoconfiscate.sh and ./configure I'm not a wiz when it comes to these Makefile and environmental things. I know I've updated things since the last time I've initialized the environment in my tree. Not sure if there's a way to "automagically" make the environment reset, but I wish it was more obvious why the failure occurred! I'll dig into the code now :-) I'm running tests while looking... John From jferlan at redhat.com Fri Aug 23 21:16:26 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 17:16:26 -0400 Subject: [Libvirt-cim] [PATCH 3/4] libxkutil: Provide easy access to the libvirt capabilities In-Reply-To: <1376578102-2909-4-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-4-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5217D12A.90100@redhat.com> On 08/15/2013 10:48 AM, Viktor Mihajlovski wrote: > From: Boris Fiuczynski > > Introspecting the libvirt capabilities and creating an internal capabilities > data structure. Methods are provided for retrieving default values regarding > architecture, machine and emulator for easy of use in the provider code. > > Further, xml_parse_test was extendend to display hypervisor capabilities > and defaults. > > Signed-off-by: Boris Fiuczynski > Signed-off-by: Viktor Mihajlovski > --- > libxkutil/Makefile.am | 2 + > libxkutil/capability_parsing.c | 462 ++++++++++++++++++++++++++++++++++++++++ > libxkutil/capability_parsing.h | 93 ++++++++ > libxkutil/xml_parse_test.c | 134 +++++++++++- > 4 files changed, 688 insertions(+), 3 deletions(-) > create mode 100644 libxkutil/capability_parsing.c > create mode 100644 libxkutil/capability_parsing.h > Seems there's some duplication in a couple of places, but the capabilities checking seems to me to be the better way to go about things. I remember reviewing something recently regarding checking for "kvm" - perhaps in device_parsing.c (a quick cscope search on "kvm") In any case, this looks good and has passed both the cimtest and coverity tests ACK, John From jferlan at redhat.com Fri Aug 23 21:48:27 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 17:48:27 -0400 Subject: [Libvirt-cim] [PATCH 4/4] VSSM: Set default values based on libvirt capabilities on DefineSystem calls In-Reply-To: <1376578102-2909-5-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-5-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5217D8AB.7090709@redhat.com> On 08/15/2013 10:48 AM, Viktor Mihajlovski wrote: > From: Boris Fiuczynski > > In the DefineSystem call the architecture, machine and emulator for KVM are set > to the hypervisor-specific default values if they did not get provided. > This now allows architecture based decision making in the CIM providers to > work for all platforms. > > Signed-off-by: Boris Fiuczynski > Reviewed-by: Viktor Mihajlovski > --- > src/Virt_VirtualSystemManagementService.c | 130 ++++++++++++----------------- > 1 file changed, 55 insertions(+), 75 deletions(-) > This patch had some coverity - resource_leak issues... See below And fails cimtest miserably... I'll dig some more later to see if I find something, but I have to leave for the day now... > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 3fad33b..b0d81d1 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -35,6 +35,7 @@ > #include "cs_util.h" > #include "misc_util.h" > #include "device_parsing.h" > +#include "capability_parsing.h" > #include "xmlgen.h" > > #include > @@ -388,59 +389,6 @@ static bool fv_set_emulator(struct domain *domain, > return true; > } > > -static bool system_has_kvm(const char *pfx) > -{ > - CMPIStatus s; > - virConnectPtr conn = NULL; > - char *caps = NULL; > - bool disable_kvm = get_disable_kvm(); > - xmlDocPtr doc = NULL; > - xmlNodePtr node = NULL; > - int len; > - bool kvm = false; > - > - /* sometimes disable KVM to avoid problem in nested KVM */ > - if (disable_kvm) { > - CU_DEBUG("Enter disable kvm mode!"); > - goto out; > - } > - > - conn = connect_by_classname(_BROKER, pfx, &s); > - if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { > - goto out; > - } > - > - caps = virConnectGetCapabilities(conn); > - if (caps != NULL) { > - len = strlen(caps) + 1; > - > - doc = xmlParseMemory(caps, len); > - if (doc == NULL) { > - CU_DEBUG("xmlParseMemory() call failed!"); > - goto out; > - } > - > - node = xmlDocGetRootElement(doc); > - if (node == NULL) { > - CU_DEBUG("xmlDocGetRootElement() call failed!"); > - goto out; > - } > - > - if (has_kvm_domain_type(node)) { > - CU_DEBUG("The system support kvm!"); > - kvm = true; > - } > - } > - > -out: > - free(caps); > - free(doc); > - > - virConnectClose(conn); > - > - return kvm; > -} > - > static int bootord_vssd_to_domain(CMPIInstance *inst, > struct domain *domain) > { > @@ -511,13 +459,17 @@ static int bootord_vssd_to_domain(CMPIInstance *inst, > > static int fv_vssd_to_domain(CMPIInstance *inst, > struct domain *domain, > - const char *pfx) > + const char *pfx, > + virConnectPtr conn) > { > int ret; > const char *val; > + struct capabilities *capsinfo = NULL; > + > + get_capabilities(conn, &capsinfo); (1) Event alloc_arg: "get_capabilities(virConnectPtr, struct capabilities **)" allocates memory that is stored into "capsinfo". [details] Also see events: [leaked_storage] Secondary to that if get_capabilities() fails, then there's bound to be some nasty failures after this... > > if (STREQC(pfx, "KVM")) { > - if (system_has_kvm(pfx)) > + if (use_kvm(capsinfo)) > domain->type = DOMAIN_KVM; > else > domain->type = DOMAIN_QEMU; ... 478 } else { 479 CU_DEBUG("Unknown fullvirt domain type: %s", pfx); (6) Event leaked_storage: Variable "capsinfo" going out of scope leaks the storage it points to. Also see events: [alloc_arg] 480 return 0; 481 } ... 'capsinfo' is leaked > @@ -532,30 +484,49 @@ static int fv_vssd_to_domain(CMPIInstance *inst, > if (ret != 1) > return 0; Same here > > - ret = cu_get_str_prop(inst, "Emulator", &val); > - if (ret != CMPI_RC_OK) > - val = NULL; > - else if (disk_type_from_file(val) == DISK_UNKNOWN) { > - CU_DEBUG("Emulator path does not exist: %s", val); > - return 0; > - } > - > - if (!fv_set_emulator(domain, val)) > - return 0; > - > free(domain->os_info.fv.arch); > ret = cu_get_str_prop(inst, "Arch", &val); > - if (ret == CMPI_RC_OK) > + if (ret != CMPI_RC_OK) { > + if (capsinfo != NULL) { /* set default */ > + val = get_default_arch(capsinfo, "hvm"); > + CU_DEBUG("Set Arch to default: %s", val); > + } else > + val = NULL; > + } > + if (val != NULL) > domain->os_info.fv.arch = strdup(val); > - else > - domain->os_info.fv.arch = NULL; > > free(domain->os_info.fv.machine); > ret = cu_get_str_prop(inst, "Machine", &val); > - if (ret == CMPI_RC_OK) > + if (ret != CMPI_RC_OK) { > + if (capsinfo != NULL) { /* set default */ > + val = get_default_machine(capsinfo, "hvm", > + domain->os_info.fv.arch, > + "kvm"); > + CU_DEBUG("Set Machine to default: %s", val); > + } else > + val = NULL; > + } > + if (val != NULL) > domain->os_info.fv.machine = strdup(val); > - else > - domain->os_info.fv.machine = NULL; > + > + ret = cu_get_str_prop(inst, "Emulator", &val); > + if (ret != CMPI_RC_OK) { > + if (capsinfo != NULL) { /* set default */ > + val = get_default_emulator(capsinfo, "hvm", > + domain->os_info.fv.arch, > + "kvm"); > + CU_DEBUG("Set Emulator to default: %s", val); > + } else > + val = NULL; > + } > + if (val != NULL && disk_type_from_file(val) == DISK_UNKNOWN) { > + CU_DEBUG("Emulator path does not exist: %s", val); > + return 0; Same here > + } > + > + if (!fv_set_emulator(domain, val)) > + return 0; Same here > > return 1; > } > @@ -663,6 +634,8 @@ static int vssd_to_domain(CMPIInstance *inst, > bool bool_val; > bool fullvirt; > CMPIObjectPath *opathp = NULL; > + virConnectPtr conn = NULL; > + CMPIStatus s = { CMPI_RC_OK, NULL }; > > > opathp = CMGetObjectPath(inst, NULL); > @@ -748,9 +721,16 @@ static int vssd_to_domain(CMPIInstance *inst, > } > } > > - if (fullvirt || STREQC(pfx, "KVM")) > - ret = fv_vssd_to_domain(inst, domain, pfx); > - else if (STREQC(pfx, "Xen")) > + if (fullvirt || STREQC(pfx, "KVM")) { > + conn = connect_by_classname(_BROKER, cn, &s); > + if (conn == NULL || (s.rc != CMPI_RC_OK)) { > + CU_DEBUG("libvirt connection failed"); > + ret = 0; > + goto out; > + } > + ret = fv_vssd_to_domain(inst, domain, pfx, conn); > + virConnectClose(conn); > + } else if (STREQC(pfx, "Xen")) > ret = xenpv_vssd_to_domain(inst, domain); > else if (STREQC(pfx, "LXC")) > ret = lxc_vssd_to_domain(inst, domain); > From jferlan at redhat.com Fri Aug 23 22:44:12 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 18:44:12 -0400 Subject: [Libvirt-cim] [PATCH 0/3] Address 'cimtest' issues In-Reply-To: <1376000202-20533-1-git-send-email-jferlan@redhat.com> References: <1376000202-20533-1-git-send-email-jferlan@redhat.com> Message-ID: <5217E5BC.4030007@redhat.com> On 08/08/2013 06:16 PM, John Ferlan wrote: > These patches resolve some issues with test logging and there's one test > fix that I've had just hanging around that I figure I'd put out there since > there was some activity. > > John Ferlan (3): > Allow adding bridged network for running domain > Remove extranous or unnecessary parameter from error messages > Ensure get_provider_version() returns strings as expected > > .../cimtest/Profile/03_rprofile_gi_errs.py | 2 +- > suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py | 2 +- > .../cimtest/ResourcePool/02_rp_gi_errors.py | 2 +- > .../22_addmulti_brg_interface.py | 9 +++++++-- > suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 23 +++++++++++++++++----- > 6 files changed, 29 insertions(+), 11 deletions(-) > ping? From jferlan at redhat.com Fri Aug 23 22:44:20 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 23 Aug 2013 18:44:20 -0400 Subject: [Libvirt-cim] [PATCH 0/2] Address a couple of spec file issues In-Reply-To: <1376000376-20978-1-git-send-email-jferlan@redhat.com> References: <1376000376-20978-1-git-send-email-jferlan@redhat.com> Message-ID: <5217E5C4.4050806@redhat.com> On 08/08/2013 06:19 PM, John Ferlan wrote: > These patches resolve a couple of issues with the spec file. > > John Ferlan (2): > spec: Replace the path to the tar.gz file > spec: Fix capitalization for version check > > libvirt-cim.spec.in | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > ping? From mihajlov at linux.vnet.ibm.com Mon Aug 26 14:40:50 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Mon, 26 Aug 2013 16:40:50 +0200 Subject: [Libvirt-cim] [PATCH 4/4] VSSM: Set default values based on libvirt capabilities on DefineSystem calls In-Reply-To: <5217D8AB.7090709@redhat.com> References: <1376578102-2909-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1376578102-2909-5-git-send-email-mihajlov@linux.vnet.ibm.com> <5217D8AB.7090709@redhat.com> Message-ID: <521B68F2.70409@linux.vnet.ibm.com> On 08/23/2013 11:48 PM, John Ferlan wrote: > On 08/15/2013 10:48 AM, Viktor Mihajlovski wrote: >> From: Boris Fiuczynski >> >> In the DefineSystem call the architecture, machine and emulator for KVM are set >> to the hypervisor-specific default values if they did not get provided. >> This now allows architecture based decision making in the CIM providers to >> work for all platforms. >> >> Signed-off-by: Boris Fiuczynski >> Reviewed-by: Viktor Mihajlovski >> --- >> src/Virt_VirtualSystemManagementService.c | 130 ++++++++++++----------------- >> 1 file changed, 55 insertions(+), 75 deletions(-) >> > > This patch had some coverity - resource_leak issues... See below > > And fails cimtest miserably... I'll dig some more later to see if I find something, > but I have to leave for the day now... > Thanks for the review and testing. Indeed, the memory leak was a review escape from my side. We'll send out a revised version of patches 3 and 4 soon. -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Tue Aug 27 14:40:48 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Tue, 27 Aug 2013 16:40:48 +0200 Subject: [Libvirt-cim] [PATCH 0/2] Address a couple of spec file issues In-Reply-To: <1376000376-20978-1-git-send-email-jferlan@redhat.com> References: <1376000376-20978-1-git-send-email-jferlan@redhat.com> Message-ID: <521CBA70.7040009@linux.vnet.ibm.com> On 08/09/2013 12:19 AM, John Ferlan wrote: > These patches resolve a couple of issues with the spec file. > > John Ferlan (2): > spec: Replace the path to the tar.gz file > spec: Fix capitalization for version check > > libvirt-cim.spec.in | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > [Looks good to me.] Reviewed-by: Viktor Mihajlovski -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Thu Aug 29 15:18:50 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 29 Aug 2013 17:18:50 +0200 Subject: [Libvirt-cim] [PATCHv2 2/5] VSSD: Add properties for arch and machine In-Reply-To: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1377789533-8945-3-git-send-email-mihajlov@linux.vnet.ibm.com> For architectures like s390 the machine type is relevant for the proper guest construction. We add the necessary properties to the schema and the C structures and the necessary code for CIM-to-libvirt mapping. Signed-off-by: Viktor Mihajlovski --- libxkutil/device_parsing.c | 12 ++++++++++++ libxkutil/device_parsing.h | 2 ++ libxkutil/xmlgen.c | 6 ++++++ schema/VSSD.mof | 6 ++++++ src/Virt_VSSD.c | 9 +++++++++ src/Virt_VirtualSystemManagementService.c | 14 ++++++++++++++ 6 files changed, 49 insertions(+) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 500c724..df7a87a 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1090,6 +1090,8 @@ static int parse_os(struct domain *dominfo, xmlNode *os) xmlNode *child; char **blist = NULL; unsigned bl_size = 0; + char *arch = NULL; + char *machine = NULL; char *kernel = NULL; char *initrd = NULL; char *cmdline = NULL; @@ -1100,6 +1102,8 @@ static int parse_os(struct domain *dominfo, xmlNode *os) for (child = os->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "type")) { STRPROP(dominfo, os_info.pv.type, child); + arch = get_attr_value(child, "arch"); + machine = get_attr_value(child, "machine"); } else if (XSTREQ(child->name, "kernel")) kernel = get_node_content(child); else if (XSTREQ(child->name, "initrd")) @@ -1147,9 +1151,13 @@ static int parse_os(struct domain *dominfo, xmlNode *os) case DOMAIN_KVM: case DOMAIN_QEMU: dominfo->os_info.fv.loader = loader; + dominfo->os_info.fv.arch = arch; + dominfo->os_info.fv.machine = machine; dominfo->os_info.fv.bootlist_ct = bl_size; dominfo->os_info.fv.bootlist = blist; loader = NULL; + arch = NULL; + machine = NULL; blist = NULL; bl_size = 0; break; @@ -1169,6 +1177,8 @@ static int parse_os(struct domain *dominfo, xmlNode *os) break; } + free(arch); + free(machine); free(kernel); free(initrd); free(cmdline); @@ -1372,6 +1382,8 @@ void cleanup_dominfo(struct domain **dominfo) (dom->type == DOMAIN_KVM) || (dom->type == DOMAIN_QEMU)) { free(dom->os_info.fv.type); free(dom->os_info.fv.loader); + free(dom->os_info.fv.arch); + free(dom->os_info.fv.machine); cleanup_bootlist(dom->os_info.fv.bootlist, dom->os_info.fv.bootlist_ct); } else if (dom->type == DOMAIN_LXC) { diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 2b6d3d1..379d48c 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -136,6 +136,8 @@ struct pv_os_info { struct fv_os_info { char *type; /* Should always be 'hvm' */ + char *arch; + char *machine; char *loader; unsigned bootlist_ct; char **bootlist; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 4287d42..f19830f 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -802,6 +802,12 @@ static char *_kvm_os_xml(xmlNodePtr root, struct domain *domain) if (tmp == NULL) return XML_ERROR; + if (os->arch) + xmlNewProp(tmp, BAD_CAST "arch", BAD_CAST os->arch); + + if (os->machine) + xmlNewProp(tmp, BAD_CAST "machine", BAD_CAST os->machine); + ret = _fv_bootlist_xml(root, os); if (ret == 0) return XML_ERROR; diff --git a/schema/VSSD.mof b/schema/VSSD.mof index 0359d67..2734d8e 100644 --- a/schema/VSSD.mof +++ b/schema/VSSD.mof @@ -48,6 +48,12 @@ class KVM_VirtualSystemSettingData : Virt_VirtualSystemSettingData [Description ("The emulator the guest should use during runtime.")] string Emulator; + [Description ("The guest's architecture.")] + string Arch; + + [Description ("The guest's machine type")] + string Machine; + }; [Description ( diff --git a/src/Virt_VSSD.c b/src/Virt_VSSD.c index 3363b38..67e56aa 100644 --- a/src/Virt_VSSD.c +++ b/src/Virt_VSSD.c @@ -121,6 +121,15 @@ static CMPIStatus _set_fv_prop(const CMPIBroker *broker, goto out; } + if (dominfo->os_info.fv.arch != NULL) + CMSetProperty(inst, "Arch", + (CMPIValue *)dominfo->os_info.fv.arch, + CMPI_chars); + + if (dominfo->os_info.fv.machine != NULL) + CMSetProperty(inst, "Machine", + (CMPIValue *)dominfo->os_info.fv.machine, + CMPI_chars); out: return s; } diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 8ced2d6..3df878f 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -543,6 +543,20 @@ static int fv_vssd_to_domain(CMPIInstance *inst, if (!fv_set_emulator(domain, val)) return 0; + free(domain->os_info.fv.arch); + ret = cu_get_str_prop(inst, "Arch", &val); + if (ret == CMPI_RC_OK) + domain->os_info.fv.arch = strdup(val); + else + domain->os_info.fv.arch = NULL; + + free(domain->os_info.fv.machine); + ret = cu_get_str_prop(inst, "Machine", &val); + if (ret == CMPI_RC_OK) + domain->os_info.fv.machine = strdup(val); + else + domain->os_info.fv.machine = NULL; + return 1; } -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 29 15:18:48 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 29 Aug 2013 17:18:48 +0200 Subject: [Libvirt-cim] [PATCHv2 0/5] Initial Enablement of S390 Message-ID: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> The current libvirt-cim implementation makes some assumptions that are only true for x86 architectures. As we want to enable libvirt-cim for s390 we need to makes sure that valid libvirt guest definitions are being built for that architecture while not breaking the existing implementation. Patch 1 fixes potential memory access problems. Patches 2 and 3 introduce two new properties arch and machine, effectively a pass-through of the underlying libvirt properties, for the necessary distinction between x86 and other guests, and suppress the default framebuffer for s390. Patches 4 and 5 make sure that a minimal SVPC guest definition (VSSD and RASD) will result in a correct libvirt guest definition for the current hypervisor. Boris Fiuczynski (2): libxkutil: Provide easy access to the libvirt capabilities VSSM: Set default values based on libvirt capabilities on DefineSystem calls Viktor Mihajlovski (3): libxkutil: Improve domain.os_info cleanup VSSD: Add properties for arch and machine S390: Avoid the generation of default input and graphics libxkutil/Makefile.am | 2 + libxkutil/capability_parsing.c | 556 +++++++++++++++++++++++++++++ libxkutil/capability_parsing.h | 97 +++++ libxkutil/device_parsing.c | 114 +++--- libxkutil/device_parsing.h | 4 +- libxkutil/xml_parse_test.c | 201 ++++++++++- libxkutil/xmlgen.c | 6 + schema/VSSD.mof | 6 + src/Virt_VSSD.c | 9 + src/Virt_VirtualSystemManagementService.c | 165 +++++---- 10 files changed, 1033 insertions(+), 127 deletions(-) create mode 100644 libxkutil/capability_parsing.c create mode 100644 libxkutil/capability_parsing.h V2 Changes # Split original patch 1 into 2 patches (fix, new feature), otherwise unchanged # Patch 3 also considers QEMU domains now, was KVM only # Patches 4 and 5 address memory leaks and overwrites # cimtest run completes without regressions on x86 -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 29 15:18:51 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 29 Aug 2013 17:18:51 +0200 Subject: [Libvirt-cim] [PATCHv2 3/5] S390: Avoid the generation of default input and graphics In-Reply-To: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1377789533-8945-4-git-send-email-mihajlov@linux.vnet.ibm.com> KVM guests for the s390 architecture do not support graphics and input devices. We use the os_info.fv.arch property to recognize such guests and skip the default device generation for those. Signed-off-by: Viktor Mihajlovski --- src/Virt_VirtualSystemManagementService.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) V2 Changes: suppress for KVM and QEMU s390x domains, was KVM only diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 3df878f..301f046 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -583,6 +583,12 @@ static bool default_graphics_device(struct domain *domain) if (domain->type == DOMAIN_LXC) return true; + if ((domain->type == DOMAIN_KVM || domain->type == DOMAIN_QEMU) && + domain->os_info.fv.arch != NULL && + (XSTREQ(domain->os_info.fv.arch, "s390") || + XSTREQ(domain->os_info.fv.arch, "s390x" ))) + return true; + free(domain->dev_graphics); domain->dev_graphics = calloc(1, sizeof(*domain->dev_graphics)); if (domain->dev_graphics == NULL) { @@ -605,6 +611,12 @@ static bool default_input_device(struct domain *domain) if (domain->type == DOMAIN_LXC) return true; + if ((domain->type == DOMAIN_KVM || domain->type == DOMAIN_QEMU) && + domain->os_info.fv.arch != NULL && + (XSTREQ(domain->os_info.fv.arch, "s390") || + XSTREQ(domain->os_info.fv.arch, "s390x" ))) + return true; + free(domain->dev_input); domain->dev_input = calloc(1, sizeof(*domain->dev_input)); if (domain->dev_input == NULL) { -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 29 15:18:49 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 29 Aug 2013 17:18:49 +0200 Subject: [Libvirt-cim] [PATCHv2 1/5] libxkutil: Improve domain.os_info cleanup In-Reply-To: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1377789533-8945-2-git-send-email-mihajlov@linux.vnet.ibm.com> The union fields in os_info were set by means of XML parsing which doesn't take into account that certain fields are depending on the virtualization type. This could lead both to memory overwrites and memory leaks. Fixed by using temporary variables and type-based setting of fields Signed-off-by: Viktor Mihajlovski --- libxkutil/device_parsing.c | 73 +++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index ffdf682..500c724 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1077,23 +1077,37 @@ int parse_fq_devid(const char *devid, char **host, char **device) return 1; } +static void cleanup_bootlist(char **blist, unsigned blist_ct) +{ + while (blist_ct > 0) { + free(blist[--blist_ct]); + } + free(blist); +} + static int parse_os(struct domain *dominfo, xmlNode *os) { xmlNode *child; char **blist = NULL; unsigned bl_size = 0; + char *kernel = NULL; + char *initrd = NULL; + char *cmdline = NULL; + char *loader = NULL; + char *boot = NULL; + char *init = NULL; for (child = os->children; child != NULL; child = child->next) { - if (XSTREQ(child->name, "type")) + if (XSTREQ(child->name, "type")) { STRPROP(dominfo, os_info.pv.type, child); - else if (XSTREQ(child->name, "kernel")) - STRPROP(dominfo, os_info.pv.kernel, child); + } else if (XSTREQ(child->name, "kernel")) + kernel = get_node_content(child); else if (XSTREQ(child->name, "initrd")) - STRPROP(dominfo, os_info.pv.initrd, child); + initrd = get_node_content(child); else if (XSTREQ(child->name, "cmdline")) - STRPROP(dominfo, os_info.pv.cmdline, child); + cmdline = get_node_content(child); else if (XSTREQ(child->name, "loader")) - STRPROP(dominfo, os_info.fv.loader, child); + loader = get_node_content(child); else if (XSTREQ(child->name, "boot")) { char **tmp_list = NULL; @@ -1111,7 +1125,7 @@ static int parse_os(struct domain *dominfo, xmlNode *os) blist[bl_size] = get_attr_value(child, "dev"); bl_size++; } else if (XSTREQ(child->name, "init")) - STRPROP(dominfo, os_info.lxc.init, child); + init = get_node_content(child); } if ((STREQC(dominfo->os_info.fv.type, "hvm")) && @@ -1128,17 +1142,39 @@ static int parse_os(struct domain *dominfo, xmlNode *os) else dominfo->type = -1; - if (STREQC(dominfo->os_info.fv.type, "hvm")) { + switch (dominfo->type) { + case DOMAIN_XENFV: + case DOMAIN_KVM: + case DOMAIN_QEMU: + dominfo->os_info.fv.loader = loader; dominfo->os_info.fv.bootlist_ct = bl_size; dominfo->os_info.fv.bootlist = blist; - } else { - int i; - - for (i = 0; i < bl_size; i++) - free(blist[i]); - free(blist); + loader = NULL; + blist = NULL; + bl_size = 0; + break; + case DOMAIN_XENPV: + dominfo->os_info.pv.kernel = kernel; + dominfo->os_info.pv.initrd = initrd; + dominfo->os_info.pv.cmdline = cmdline; + kernel = NULL; + initrd = NULL; + cmdline = NULL; + break; + case DOMAIN_LXC: + dominfo->os_info.lxc.init = init; + init = NULL; + break; + default: + break; } + free(kernel); + free(initrd); + free(cmdline); + free(boot); + free(init); + cleanup_bootlist(blist, bl_size); return 1; } @@ -1334,15 +1370,10 @@ void cleanup_dominfo(struct domain **dominfo) free(dom->os_info.pv.cmdline); } else if ((dom->type == DOMAIN_XENFV) || (dom->type == DOMAIN_KVM) || (dom->type == DOMAIN_QEMU)) { - int i; - free(dom->os_info.fv.type); free(dom->os_info.fv.loader); - - for (i = 0; i < dom->os_info.fv.bootlist_ct; i++) { - free(dom->os_info.fv.bootlist[i]); - } - free(dom->os_info.fv.bootlist); + cleanup_bootlist(dom->os_info.fv.bootlist, + dom->os_info.fv.bootlist_ct); } else if (dom->type == DOMAIN_LXC) { free(dom->os_info.lxc.type); free(dom->os_info.lxc.init); -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 29 15:18:53 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 29 Aug 2013 17:18:53 +0200 Subject: [Libvirt-cim] [PATCHv2 5/5] VSSM: Set default values based on libvirt capabilities on DefineSystem calls In-Reply-To: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1377789533-8945-6-git-send-email-mihajlov@linux.vnet.ibm.com> From: Boris Fiuczynski In the DefineSystem call the architecture, machine and emulator for KVM are set to the hypervisor-specific default values if they did not get provided. This now allows architecture based decision making in the CIM providers to work for all platforms. Signed-off-by: Boris Fiuczynski Reviewed-by: Viktor Mihajlovski --- src/Virt_VirtualSystemManagementService.c | 161 ++++++++++++++--------------- 1 file changed, 78 insertions(+), 83 deletions(-) V2 Changes + Removed memory leaks + Restricted setting machine and emulator defaults to KVM/QEMU cases diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 301f046..53b9691 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -35,6 +35,7 @@ #include "cs_util.h" #include "misc_util.h" #include "device_parsing.h" +#include "capability_parsing.h" #include "xmlgen.h" #include @@ -388,59 +389,6 @@ static bool fv_set_emulator(struct domain *domain, return true; } -static bool system_has_kvm(const char *pfx) -{ - CMPIStatus s; - virConnectPtr conn = NULL; - char *caps = NULL; - bool disable_kvm = get_disable_kvm(); - xmlDocPtr doc = NULL; - xmlNodePtr node = NULL; - int len; - bool kvm = false; - - /* sometimes disable KVM to avoid problem in nested KVM */ - if (disable_kvm) { - CU_DEBUG("Enter disable kvm mode!"); - goto out; - } - - conn = connect_by_classname(_BROKER, pfx, &s); - if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { - goto out; - } - - caps = virConnectGetCapabilities(conn); - if (caps != NULL) { - len = strlen(caps) + 1; - - doc = xmlParseMemory(caps, len); - if (doc == NULL) { - CU_DEBUG("xmlParseMemory() call failed!"); - goto out; - } - - node = xmlDocGetRootElement(doc); - if (node == NULL) { - CU_DEBUG("xmlDocGetRootElement() call failed!"); - goto out; - } - - if (has_kvm_domain_type(node)) { - CU_DEBUG("The system support kvm!"); - kvm = true; - } - } - -out: - free(caps); - free(doc); - - virConnectClose(conn); - - return kvm; -} - static int bootord_vssd_to_domain(CMPIInstance *inst, struct domain *domain) { @@ -511,53 +459,91 @@ static int bootord_vssd_to_domain(CMPIInstance *inst, static int fv_vssd_to_domain(CMPIInstance *inst, struct domain *domain, - const char *pfx) + const char *pfx, + virConnectPtr conn) { - int ret; + int ret = 1; + int retr; const char *val; + const char *domtype; + const char *ostype = "hvm"; + struct capabilities *capsinfo = NULL; + + get_capabilities(conn, &capsinfo); if (STREQC(pfx, "KVM")) { - if (system_has_kvm(pfx)) + if (use_kvm(capsinfo)) { domain->type = DOMAIN_KVM; - else + domtype = "kvm"; + } else { domain->type = DOMAIN_QEMU; + domtype = "qemu"; + } } else if (STREQC(pfx, "Xen")) { domain->type = DOMAIN_XENFV; + domtype = NULL; } else { CU_DEBUG("Unknown fullvirt domain type: %s", pfx); - return 0; + ret = 0; + goto out; } - ret = bootord_vssd_to_domain(inst, domain); - if (ret != 1) - return 0; - - ret = cu_get_str_prop(inst, "Emulator", &val); - if (ret != CMPI_RC_OK) - val = NULL; - else if (disk_type_from_file(val) == DISK_UNKNOWN) { - CU_DEBUG("Emulator path does not exist: %s", val); - return 0; + retr = bootord_vssd_to_domain(inst, domain); + if (retr != 1) { + ret = 0; + goto out; } - if (!fv_set_emulator(domain, val)) - return 0; - free(domain->os_info.fv.arch); - ret = cu_get_str_prop(inst, "Arch", &val); - if (ret == CMPI_RC_OK) + retr = cu_get_str_prop(inst, "Arch", &val); + if (retr != CMPI_RC_OK) { + if (capsinfo != NULL) { /* set default */ + val = get_default_arch(capsinfo, ostype); + CU_DEBUG("Set Arch to default: %s", val); + } else + val = NULL; + } + if (val != NULL) domain->os_info.fv.arch = strdup(val); - else - domain->os_info.fv.arch = NULL; free(domain->os_info.fv.machine); - ret = cu_get_str_prop(inst, "Machine", &val); - if (ret == CMPI_RC_OK) + retr = cu_get_str_prop(inst, "Machine", &val); + if (retr != CMPI_RC_OK) { + if (capsinfo != NULL && domtype != NULL) { /* set default */ + val = get_default_machine(capsinfo, ostype, + domain->os_info.fv.arch, + domtype); + CU_DEBUG("Set Machine to default: %s", val); + } else + val = NULL; + } + if (val != NULL) domain->os_info.fv.machine = strdup(val); - else - domain->os_info.fv.machine = NULL; - return 1; + retr = cu_get_str_prop(inst, "Emulator", &val); + if (retr != CMPI_RC_OK) { + if (capsinfo != NULL && domtype != NULL) { /* set default */ + val = get_default_emulator(capsinfo, ostype, + domain->os_info.fv.arch, + domtype); + CU_DEBUG("Set Emulator to default: %s", val); + } else + val = NULL; + } + if (val != NULL && disk_type_from_file(val) == DISK_UNKNOWN) { + CU_DEBUG("Emulator path does not exist: %s", val); + ret = 0; + goto out; + } + + if (!fv_set_emulator(domain, val)) { + ret = 0; + goto out; + } + + out: + cleanup_capabilities(&capsinfo); + return ret; } static int lxc_vssd_to_domain(CMPIInstance *inst, @@ -663,6 +649,8 @@ static int vssd_to_domain(CMPIInstance *inst, bool bool_val; bool fullvirt; CMPIObjectPath *opathp = NULL; + virConnectPtr conn = NULL; + CMPIStatus s = { CMPI_RC_OK, NULL }; opathp = CMGetObjectPath(inst, NULL); @@ -748,9 +736,16 @@ static int vssd_to_domain(CMPIInstance *inst, } } - if (fullvirt || STREQC(pfx, "KVM")) - ret = fv_vssd_to_domain(inst, domain, pfx); - else if (STREQC(pfx, "Xen")) + if (fullvirt || STREQC(pfx, "KVM")) { + conn = connect_by_classname(_BROKER, cn, &s); + if (conn == NULL || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("libvirt connection failed"); + ret = 0; + goto out; + } + ret = fv_vssd_to_domain(inst, domain, pfx, conn); + virConnectClose(conn); + } else if (STREQC(pfx, "Xen")) ret = xenpv_vssd_to_domain(inst, domain); else if (STREQC(pfx, "LXC")) ret = lxc_vssd_to_domain(inst, domain); -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Aug 29 15:18:52 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 29 Aug 2013 17:18:52 +0200 Subject: [Libvirt-cim] [PATCHv2 4/5] libxkutil: Provide easy access to the libvirt capabilities In-Reply-To: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1377789533-8945-5-git-send-email-mihajlov@linux.vnet.ibm.com> From: Boris Fiuczynski Introspecting the libvirt capabilities and creating an internal capabilities data structure. Methods are provided for retrieving default values regarding architecture, machine and emulator for easy of use in the provider code. Changed the KVM detection to use the capabilities instead of unique XML parsing. Further, xml_parse_test was extendend to display hypervisor capabilities and defaults. Signed-off-by: Boris Fiuczynski Signed-off-by: Viktor Mihajlovski --- libxkutil/Makefile.am | 2 + libxkutil/capability_parsing.c | 556 ++++++++++++++++++++++++++++++++++++++++ libxkutil/capability_parsing.h | 97 +++++++ libxkutil/device_parsing.c | 29 --- libxkutil/device_parsing.h | 2 - libxkutil/xml_parse_test.c | 201 ++++++++++++++- 6 files changed, 853 insertions(+), 34 deletions(-) create mode 100644 libxkutil/capability_parsing.c create mode 100644 libxkutil/capability_parsing.h V2 Changes + Removed memory leaks + Removed occurrence of crashes when multiple guests are defined + Corrected search pattern for default architecture and machine + Added host CPU architecture parsing + Extended xml_parse_test with better testing capabilities coverage + Wrong free on cap guest struct + Fixed use_kvm method diff --git a/libxkutil/Makefile.am b/libxkutil/Makefile.am index 8d436ad..dd7be55 100644 --- a/libxkutil/Makefile.am +++ b/libxkutil/Makefile.am @@ -7,6 +7,7 @@ noinst_HEADERS = \ cs_util.h \ misc_util.h \ device_parsing.h \ + capability_parsing.h \ xmlgen.h \ infostore.h \ pool_parsing.h \ @@ -20,6 +21,7 @@ libxkutil_la_SOURCES = \ cs_util_instance.c \ misc_util.c \ device_parsing.c \ + capability_parsing.c \ xmlgen.c \ infostore.c \ pool_parsing.c \ diff --git a/libxkutil/capability_parsing.c b/libxkutil/capability_parsing.c new file mode 100644 index 0000000..e3c0f2b --- /dev/null +++ b/libxkutil/capability_parsing.c @@ -0,0 +1,556 @@ +/* + * Copyright IBM Corp. 2013 + * + * Authors: + * Boris Fiuczynski + * + * 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 "misc_util.h" +#include "capability_parsing.h" +#include "xmlgen.h" +#include "../src/svpc_types.h" + +static void cleanup_cap_machine(struct cap_machine *machine) +{ + if (machine == NULL) + return; + free(machine->name); + free(machine->canonical_name); +} + +static void cleanup_cap_domain_info(struct cap_domain_info *cgdi) +{ + int i; + if (cgdi == NULL) + return; + free(cgdi->emulator); + free(cgdi->loader); + for (i = 0; i < cgdi->num_machines; i++) + cleanup_cap_machine(&cgdi->machines[i]); + free(cgdi->machines); +} + +static void cleanup_cap_domain(struct cap_domain *cgd) +{ + if (cgd == NULL) + return; + free(cgd->typestr); + cleanup_cap_domain_info(&cgd->guest_domain_info); +} + +static void cleanup_cap_arch(struct cap_arch *cga) +{ + int i; + if (cga == NULL) + return; + free(cga->name); + cleanup_cap_domain_info(&cga->default_domain_info); + for (i = 0; i < cga->num_domains; i++) + cleanup_cap_domain(&cga->domains[i]); + free(cga->domains); +} + +static void cleanup_cap_guest(struct cap_guest *cg) +{ + if (cg == NULL) + return; + free(cg->ostype); + cleanup_cap_arch(&cg->arch); +} + +static void cleanup_cap_host(struct cap_host *ch) +{ + if (ch == NULL) + return; + free(ch->cpu_arch); +} + +void cleanup_capabilities(struct capabilities **caps) +{ + int i; + struct capabilities *cap; + + if ((caps == NULL) || (*caps == NULL)) + return; + + cap = *caps; + cleanup_cap_host(&cap->host); + for (i = 0; i < cap->num_guests; i++) + cleanup_cap_guest(&cap->guests[i]); + + free(cap->guests); + free(cap); + *caps = NULL; +} + +static void extend_cap_machines(struct cap_domain_info *cg_domaininfo, + char *name, char *canonical_name) +{ + struct cap_machine *tmp_list = NULL; + tmp_list = realloc(cg_domaininfo->machines, + (cg_domaininfo->num_machines + 1) * + sizeof(struct cap_machine)); + + if (tmp_list == NULL) { + /* Nothing you can do. Just go on. */ + CU_DEBUG("Could not alloc space for " + "guest domain info list"); + return; + } + cg_domaininfo->machines = tmp_list; + + struct cap_machine *cap_gm = + &cg_domaininfo->machines[cg_domaininfo->num_machines]; + cap_gm->name = name; + cap_gm->canonical_name = canonical_name; + cg_domaininfo->num_machines++; +} + +static void parse_cap_domain_info(struct cap_domain_info *cg_domaininfo, + xmlNode *domain_child_node) +{ + CU_DEBUG("Capabilities guest domain info element node: %s", + domain_child_node->name); + + if (XSTREQ(domain_child_node->name, "emulator")) { + cg_domaininfo->emulator = + get_node_content(domain_child_node); + } else if (XSTREQ(domain_child_node->name, "loader")) { + cg_domaininfo->loader = + get_node_content(domain_child_node); + } else if (XSTREQ(domain_child_node->name, "machine")) { + extend_cap_machines(cg_domaininfo, + get_node_content(domain_child_node), + get_attr_value(domain_child_node, + "canonical")); + } +} + +static void parse_cap_domain(struct cap_domain *cg_domain, + xmlNode *guest_dom) +{ + CU_DEBUG("Capabilities guest domain node: %s", guest_dom->name); + + xmlNode *child; + + cg_domain->typestr = get_attr_value(guest_dom, "type"); + + for (child = guest_dom->children; child != NULL; child = child->next) + parse_cap_domain_info(&cg_domain->guest_domain_info, child); +} + +static void parse_cap_arch(struct cap_arch *cg_archinfo, + xmlNode *arch) +{ + CU_DEBUG("Capabilities arch node: %s", arch->name); + + xmlNode *child; + + cg_archinfo->name = get_attr_value(arch, "name"); + + for (child = arch->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "wordsize")) { + char *wordsize_str; + unsigned int wordsize; + wordsize_str = get_node_content(child); + /* Default to 0 wordsize if garbage */ + if (wordsize_str == NULL || + sscanf(wordsize_str, "%i", &wordsize) != 1) + wordsize = 0; + free(wordsize_str); + cg_archinfo->wordsize = wordsize; + } else if (XSTREQ(child->name, "domain")) { + struct cap_domain *tmp_list = NULL; + tmp_list = realloc(cg_archinfo->domains, + (cg_archinfo->num_domains + 1) * + sizeof(struct cap_domain)); + if (tmp_list == NULL) { + /* Nothing you can do. Just go on. */ + CU_DEBUG("Could not alloc space for " + "guest domain"); + continue; + } + memset(&tmp_list[cg_archinfo->num_domains], + 0, sizeof(struct cap_domain)); + cg_archinfo->domains = tmp_list; + parse_cap_domain(&cg_archinfo-> + domains[cg_archinfo->num_domains], + child); + cg_archinfo->num_domains++; + } else { + /* Check for the default domain child nodes */ + parse_cap_domain_info(&cg_archinfo->default_domain_info, + child); + } + } +} + +static void parse_cap_guests(xmlNodeSet *nsv, struct cap_guest *cap_guests) +{ + xmlNode **nodes = nsv->nodeTab; + xmlNode *child; + int numGuestNodes = nsv->nodeNr; + int i; + + for (i = 0; i < numGuestNodes; i++) { + for (child = nodes[i]->children; child != NULL; + child = child->next) { + if (XSTREQ(child->name, "os_type")) { + STRPROP((&cap_guests[i]), ostype, child); + } else if (XSTREQ(child->name, "arch")) { + parse_cap_arch(&cap_guests[i].arch, child); + } + } + } +} + +static int parse_cap_host_cpu(struct cap_host *cap_host, xmlNode *cpu) +{ + xmlNode *child; + + for (child = cpu->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "arch")) { + cap_host->cpu_arch = get_node_content(child); + if (cap_host->cpu_arch != NULL) + return 1; /* success - host arch node found */ + else { + CU_DEBUG("Host architecture is not defined"); + break; + } + } + } + return 0; /* error - no arch node or empty arch node */ +} + +static int parse_cap_host(xmlNodeSet *nsv, struct cap_host *cap_host) +{ + xmlNode **nodes = nsv->nodeTab; + xmlNode *child; + if (nsv->nodeNr < 1) + return 0; /* error no node below host */ + + for (child = nodes[0]->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "cpu")) + return parse_cap_host_cpu(cap_host, child); + } + return 0; /* error - no cpu node */ +} + +static void compare_copy_domain_info_machines( + struct cap_domain_info *def_gdomi, + struct cap_domain_info *cap_gadomi) +{ + int i,j; + int org_l = cap_gadomi->num_machines; + char *cp_name = NULL; + char *cp_canonical_name = NULL; + bool found; + + for (i = 0; i < def_gdomi->num_machines; i++) { + found = false; + for (j = 0; j < org_l; j++) { + if (STREQC(def_gdomi->machines[i].name, + cap_gadomi->machines[j].name)) { + found = true; + continue; + /* found match => check next default */ + } + } + if (!found) { /* no match => insert default */ + cp_name = NULL; + cp_canonical_name = NULL; + if (def_gdomi->machines[i].name != NULL) + cp_name = strdup(def_gdomi->machines[i].name); + if (def_gdomi->machines[i].canonical_name != NULL) + cp_canonical_name = + strdup(def_gdomi-> + machines[i].canonical_name); + + extend_cap_machines(cap_gadomi, + cp_name, + cp_canonical_name); + } + } +} + +static void extend_defaults_cap_guests(struct capabilities *caps) +{ + struct cap_arch *cap_garch; + struct cap_domain_info *cap_gadomi; + struct cap_domain_info *def_gdomi; + int i,j; + + if (caps == NULL) + return; + + for (i = 0; i < caps->num_guests; i++) { + cap_garch = &caps->guests[i].arch; + def_gdomi = &cap_garch->default_domain_info; + + for (j = 0; j < cap_garch->num_domains; j++) { + /* compare guest_domain_info */ + cap_gadomi = &cap_garch->domains[j].guest_domain_info; + if (cap_gadomi->emulator == NULL && + def_gdomi->emulator != NULL) + cap_gadomi->emulator = + strdup(def_gdomi->emulator); + if (cap_gadomi->loader == NULL && + def_gdomi->loader != NULL) + cap_gadomi->loader = strdup(def_gdomi->loader); + + compare_copy_domain_info_machines(def_gdomi, + cap_gadomi); + } + } +} + +static int _get_capabilities(const char *xml, struct capabilities *caps) +{ + int len; + int ret = 0; + + xmlDoc *xmldoc = NULL; + xmlXPathContext *xpathctx = NULL; + xmlXPathObject *xpathobj = NULL; + const xmlChar *xpathhoststr = (xmlChar *)"//capabilities//host"; + const xmlChar *xpathgueststr = (xmlChar *)"//capabilities//guest"; + xmlNodeSet *nsv; + + len = strlen(xml) + 1; + + if ((xmldoc = xmlParseMemory(xml, len)) == NULL) + goto err; + + if ((xpathctx = xmlXPathNewContext(xmldoc)) == NULL) + goto err; + + /* host node */ + if ((xpathobj = xmlXPathEvalExpression(xpathhoststr, xpathctx)) == NULL) + goto err; + if (xmlXPathNodeSetIsEmpty(xpathobj->nodesetval)) { + CU_DEBUG("No capabilities host node found!"); + goto err; + } + + nsv = xpathobj->nodesetval; + if (!parse_cap_host(nsv, &caps->host)) + goto err; + xmlXPathFreeObject(xpathobj); + + /* all guest nodes */ + if ((xpathobj = xmlXPathEvalExpression(xpathgueststr, xpathctx)) == NULL) + goto err; + if (xmlXPathNodeSetIsEmpty(xpathobj->nodesetval)) { + CU_DEBUG("No capabilities guest nodes found!"); + goto err; + } + + nsv = xpathobj->nodesetval; + caps->guests = calloc(nsv->nodeNr, sizeof(struct cap_guest)); + if (caps->guests == NULL) + goto err; + caps->num_guests = nsv->nodeNr; + + parse_cap_guests(nsv, caps->guests); + extend_defaults_cap_guests(caps); + ret = 1; + + err: + xmlXPathFreeObject(xpathobj); + xmlXPathFreeContext(xpathctx); + xmlFreeDoc(xmldoc); + return ret; +} + +int get_caps_from_xml(const char *xml, struct capabilities **caps) +{ + CU_DEBUG("In get_caps_from_xml"); + + free(*caps); + *caps = calloc(1, sizeof(struct capabilities)); + if (*caps == NULL) + goto err; + + if (_get_capabilities(xml, *caps) == 0) + goto err; + + return 1; + + err: + free(*caps); + *caps = NULL; + return 0; +} + +int get_capabilities(virConnectPtr conn, struct capabilities **caps) +{ + char *caps_xml = NULL; + int ret = 0; + + if (conn == NULL) { + CU_DEBUG("Unable to connect to libvirt."); + return 0; + } + + caps_xml = virConnectGetCapabilities(conn); + + if (caps_xml == NULL) { + CU_DEBUG("Unable to get capabilities xml."); + return 0; + } + + ret = get_caps_from_xml(caps_xml, caps); + + free(caps_xml); + + return ret; +} + +struct cap_domain_info *findDomainInfo(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type) +{ + int i,j; + struct cap_arch *ar; + + for (i = 0; i < caps->num_guests; i++) { + if (os_type == NULL || + STREQC(caps->guests[i].ostype, os_type)) { + ar = &caps->guests[i].arch; + if (arch == NULL || STREQC(ar->name,arch)) + for (j = 0; j < ar->num_domains; j++) + if (domain_type == NULL || + STREQC(ar->domains[j].typestr, + domain_type)) + return &ar->domains[j]. + guest_domain_info; + } + } + return NULL; +} + +static char *_findDefArch(struct capabilities *caps, + const char *os_type, + const char *host_arch) +{ + char *ret = NULL; + int i; + + if (os_type == NULL) + return NULL; + + for (i = 0; i < caps->num_guests; i++) + if (STREQC(caps->guests[i].ostype, os_type) && + (host_arch == NULL || (host_arch != NULL && + STREQC(caps->guests[i].arch.name, host_arch)))) { + ret = caps->guests[i].arch.name; + break; + } + return ret; +} + +char *get_default_arch(struct capabilities *caps, + const char *os_type) +{ + char *ret = NULL; + + if (caps != NULL) { + if (os_type != NULL) { + /* search first guest matching os_type and host arch */ + ret = _findDefArch(caps, os_type, caps->host.cpu_arch); + if (ret== NULL) /* search first matching guest */ + ret = _findDefArch(caps, os_type, NULL); + } + } + return ret; +} + +char *get_default_machine( + struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type) +{ + char *ret = NULL; + struct cap_domain_info *di; + + if (caps != NULL) { + di = findDomainInfo(caps, os_type, arch, domain_type); + if (di != NULL && di->num_machines > 0) { + ret = di->machines[0].canonical_name; + if (ret == NULL) { + ret = di->machines[0].name; + } + } + } + return ret; +} + +char *get_default_emulator(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type) +{ + char *ret = NULL; + struct cap_domain_info *di; + + if (caps != NULL) { + di = findDomainInfo(caps, os_type, arch, domain_type); + if (di != NULL) + ret = di->emulator; + } + return ret; +} + +bool use_kvm(struct capabilities *caps) { + if (host_supports_kvm(caps) && !get_disable_kvm()) + return true; + else + return false; +} + +bool host_supports_kvm(struct capabilities *caps) +{ + bool kvm = false; + if (caps != NULL) + if (findDomainInfo(caps, NULL, NULL, "kvm") != NULL) + kvm = true; + return kvm; +} +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/libxkutil/capability_parsing.h b/libxkutil/capability_parsing.h new file mode 100644 index 0000000..d258f62 --- /dev/null +++ b/libxkutil/capability_parsing.h @@ -0,0 +1,97 @@ +/* + * Copyright IBM Corp. 2013 + * + * Authors: + * Boris Fiuczynski + * + * 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 + */ +#ifndef __CAPABILITY_PARSING_H +#define __CAPABILITY_PARSING_H + +#include +#include + +struct cap_host { + char *cpu_arch; +}; + +struct cap_machine { + char *name; + char *canonical_name; +}; + +struct cap_domain_info { + char *emulator; + char *loader; + int num_machines; + struct cap_machine *machines; +}; + +struct cap_domain { + char *typestr; + struct cap_domain_info guest_domain_info; +}; + +struct cap_arch { + char *name; + unsigned int wordsize; + struct cap_domain_info default_domain_info; + int num_domains; + struct cap_domain *domains; +}; + +struct cap_guest { + char *ostype; + struct cap_arch arch; +}; + +struct capabilities { + struct cap_host host; + int num_guests; + struct cap_guest *guests; +}; + +int get_caps_from_xml(const char *xml, struct capabilities **caps); +int get_capabilities(virConnectPtr conn, struct capabilities **caps); +char *get_default_arch(struct capabilities *caps, + const char *os_type); +char *get_default_machine(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type); +char *get_default_emulator(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type); +struct cap_domain_info *findDomainInfo(struct capabilities *caps, + const char *os_type, + const char *arch, + const char *domain_type); +bool use_kvm(struct capabilities *caps); +bool host_supports_kvm(struct capabilities *caps); +void cleanup_capabilities(struct capabilities **caps); + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index df7a87a..449f51c 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -397,35 +397,6 @@ err: return 0; } -bool has_kvm_domain_type(xmlNodePtr node) -{ - xmlNodePtr child = NULL; - char *type = NULL; - bool ret = false; - - child = node->children; - while (child != NULL) { - if (XSTREQ(child->name, "domain")) { - type = get_attr_value(child, "type"); - if (XSTREQ(type, "kvm")) { - ret = true; - goto out; - } - } - - if (has_kvm_domain_type(child) == 1) { - ret = true; - goto out; - } - - child = child->next; - } - - out: - free(type); - return ret; -} - static int parse_net_device(xmlNode *inode, struct virt_device **vdevs) { struct virt_device *vdev = NULL; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 379d48c..a39e881 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -223,8 +223,6 @@ int attach_device(virDomainPtr dom, struct virt_device *dev); int detach_device(virDomainPtr dom, struct virt_device *dev); int change_device(virDomainPtr dom, struct virt_device *dev); -bool has_kvm_domain_type(xmlNodePtr node); - #define XSTREQ(x, y) (STREQ((char *)x, y)) #define STRPROP(d, p, n) (d->p = get_node_content(n)) diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c index 384593d..de2c88a 100644 --- a/libxkutil/xml_parse_test.c +++ b/libxkutil/xml_parse_test.c @@ -6,6 +6,7 @@ #include #include "device_parsing.h" +#include "capability_parsing.h" #include "xmlgen.h" static void print_value(FILE *d, const char *name, const char *val) @@ -25,6 +26,36 @@ static void print_u32(FILE *d, const char *name, uint32_t val) } #endif +static char *get_ostype(struct domain *dom) +{ + if (dom->type == DOMAIN_XENPV) { + return dom->os_info.pv.type; + } else if ((dom->type == DOMAIN_XENFV) || + (dom->type == DOMAIN_KVM) || + (dom->type == DOMAIN_QEMU)) { + return dom->os_info.fv.type; + } else if (dom->type == DOMAIN_LXC) { + return dom->os_info.lxc.type; + } else { + return NULL; + } +} + +static char *get_domaintype(struct domain *dom) +{ + if (dom->type == DOMAIN_XENPV || dom->type == DOMAIN_XENFV) { + return "xen"; + } else if (dom->type == DOMAIN_KVM) { + return "kvm"; + } else if (dom->type == DOMAIN_QEMU) { + return "qemu"; + } else if (dom->type == DOMAIN_LXC) { + return "lxc"; + } else { + return NULL; + } +} + static void print_os(struct domain *dom, FILE *d) { @@ -183,6 +214,98 @@ static char *read_from_file(FILE *file) return xml; } +static void print_cap_domain_info(struct cap_domain_info *capgdiinfo, + FILE *d) +{ + struct cap_machine capgminfo; + int i; + + if (capgdiinfo==NULL) + return; + + if (capgdiinfo->emulator!=NULL) + print_value(d, " Emulator", capgdiinfo->emulator); + if (capgdiinfo->loader!=NULL) + print_value(d, " Loader", capgdiinfo->loader); + for (i = 0; i < capgdiinfo->num_machines; i++) { + capgminfo = capgdiinfo->machines[i]; + fprintf(d, " Machine name : %-15s canonical name : %s\n", + capgminfo.name, capgminfo.canonical_name); + } + fprintf(d, "\n"); +} + +static void print_cap_domains(struct cap_arch caparchinfo, + FILE *d) +{ + struct cap_domain capgdinfo; + int i; + for (i = 0; i < caparchinfo.num_domains; i++) { + capgdinfo = caparchinfo.domains[i]; + print_value(d, " Type", capgdinfo.typestr); + print_cap_domain_info(&capgdinfo.guest_domain_info, d); + } +} + +static void print_cap_arch(struct cap_arch caparchinfo, + FILE *d) +{ + print_value(d, " Arch name", caparchinfo.name); + fprintf(d, " Arch wordsize : %i\n", caparchinfo.wordsize); + fprintf(d, "\n -- Default guest domain settings --\n"); + print_cap_domain_info(&caparchinfo.default_domain_info, d); + fprintf(d, " -- Guest domains (%i) --\n", caparchinfo.num_domains); + print_cap_domains(caparchinfo, d); +} + +static void print_cap_guest(struct cap_guest *capginfo, + FILE *d) +{ + print_value(d, "Guest OS type", capginfo->ostype); + print_cap_arch(capginfo->arch, d); +} + +static void print_cap_host(struct cap_host *caphinfo, + FILE *d) +{ + print_value(d, "Host CPU architecture", caphinfo->cpu_arch); +} + +static void print_capabilities(struct capabilities *capsinfo, + FILE *d) +{ + int i; + fprintf(d, "\n### Capabilities ###\n"); + fprintf(d, "-- Host --\n"); + print_cap_host(&capsinfo->host, d); + fprintf(d, "\n-- Guest (%i) --\n", capsinfo->num_guests); + for (i = 0; i < capsinfo->num_guests; i++) + print_cap_guest(&capsinfo->guests[i], d); +} + +static int capinfo_for_dom(const char *uri, + struct domain *dominfo, + struct capabilities **capsinfo) +{ + virConnectPtr conn = NULL; + char *caps_xml = NULL; + int ret = 0; + + conn = virConnectOpen(uri); + if (conn == NULL) { + printf("Unable to connect to libvirt\n"); + goto out; + } + + ret = get_capabilities(conn, capsinfo); + + out: + free(caps_xml); + virConnectClose(conn); + + return ret; +} + static int dominfo_from_dom(const char *uri, const char *domain, struct domain **d) @@ -246,12 +369,13 @@ static int dominfo_from_file(const char *fname, struct domain **d) static void usage(void) { printf("xml_parse_test -f [FILE | -] [--xml]\n" - "xml_parse_test -d domain [--uri URI] [--xml]\n" + "xml_parse_test -d domain [--uri URI] [--xml] [--cap]\n" "\n" "-f,--file FILE Parse domain XML from file (or stdin if -)\n" "-d,--domain DOM Display dominfo for a domain from libvirt\n" "-u,--uri URI Connect to libvirt with URI\n" "-x,--xml Dump generated XML instead of summary\n" + "-c,--cap Display the libvirt default capability values for the specified domain\n" "-h,--help Display this help message\n"); } @@ -262,7 +386,10 @@ int main(int argc, char **argv) char *uri = "xen"; char *file = NULL; bool xml = false; + bool cap = false; struct domain *dominfo = NULL; + struct capabilities *capsinfo = NULL; + struct cap_domain_info *capgdinfo = NULL; int ret; static struct option lopts[] = { @@ -270,13 +397,14 @@ int main(int argc, char **argv) {"uri", 1, 0, 'u'}, {"xml", 0, 0, 'x'}, {"file", 1, 0, 'f'}, + {"cap", 0, 0, 'c'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0}}; while (1) { int optidx = 0; - c = getopt_long(argc, argv, "d:u:f:xh", lopts, &optidx); + c = getopt_long(argc, argv, "d:u:f:xch", lopts, &optidx); if (c == -1) break; @@ -297,11 +425,14 @@ int main(int argc, char **argv) xml = true; break; + case 'c': + cap = true; + break; + case '?': case 'h': usage(); return c == '?'; - }; } @@ -326,6 +457,70 @@ int main(int argc, char **argv) print_devices(dominfo, stdout); } + if (cap && file == NULL) { + ret = capinfo_for_dom(uri, dominfo, &capsinfo); + if (ret == 0) { + printf("Unable to get capsinfo\n"); + return 3; + } else { + print_capabilities(capsinfo, stdout); + const char *os_type = get_ostype(dominfo); + const char *dom_type = get_domaintype(dominfo); + const char *def_arch = get_default_arch(capsinfo, os_type); + + fprintf(stdout, "-- KVM is used: %s\n\n", (use_kvm(capsinfo)?"true":"false")); + fprintf(stdout, "-- For all following default OS type=%s\n", os_type); + fprintf(stdout, "-- Default Arch : %s\n", def_arch); + + fprintf(stdout, + "-- Default Machine for arch=NULL : %s\n", + get_default_machine(capsinfo, os_type, NULL, NULL)); + fprintf(stdout, + "-- Default Machine for arch=%s and domain type=NULL : %s\n", + def_arch, + get_default_machine(capsinfo, os_type, def_arch, NULL)); + fprintf(stdout, + "-- Default Machine for arch=%s and domain type=%s : %s\n", + def_arch, dom_type, + get_default_machine(capsinfo, os_type, def_arch, dom_type)); + fprintf(stdout, + "-- Default Machine for arch=NULL and domain type=%s : %s\n", + dom_type, + get_default_machine(capsinfo, os_type, NULL, dom_type)); + + fprintf(stdout, + "-- Default Emulator for arch=NULL : %s\n", + get_default_emulator(capsinfo, os_type, NULL, NULL)); + fprintf(stdout, + "-- Default Emulator for arch=%s and domain type=NULL : %s\n", + def_arch, + get_default_emulator(capsinfo, os_type, def_arch, NULL)); + fprintf(stdout, + "-- Default Emulator for arch=%s and domain type=%s : %s\n", + def_arch, dom_type, + get_default_emulator(capsinfo, os_type, def_arch, dom_type)); + fprintf(stdout, + "-- Default Emulator for arch=NULL and domain type=%s : %s\n", + dom_type, + get_default_emulator(capsinfo, os_type, NULL, dom_type)); + + fprintf(stdout, "\n-- Default Domain Search for: \n" + "guest type=hvm - guest arch=* - guest domain type=kvm\n"); + capgdinfo = findDomainInfo(capsinfo, "hvm", NULL, "kvm"); + print_cap_domain_info(capgdinfo, stdout); + + fprintf(stdout, "-- Default Domain Search for: \n" + "guest type=* - guest arch=* - guest domain type=*\n"); + capgdinfo = findDomainInfo(capsinfo, NULL, NULL, NULL); + print_cap_domain_info(capgdinfo, stdout); + + cleanup_capabilities(&capsinfo); + } + } else if (cap) { + printf("Need a data source (--domain) to get default capabilities\n"); + return 4; + } + return 0; } -- 1.7.9.5 From jferlan at redhat.com Thu Aug 29 20:28:33 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 29 Aug 2013 16:28:33 -0400 Subject: [Libvirt-cim] [PATCHv2 4/5] libxkutil: Provide easy access to the libvirt capabilities In-Reply-To: <1377789533-8945-5-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1377789533-8945-5-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <521FAEF1.9010602@redhat.com> On 08/29/2013 11:18 AM, Viktor Mihajlovski wrote: > From: Boris Fiuczynski > > Introspecting the libvirt capabilities and creating an internal capabilities > data structure. Methods are provided for retrieving default values regarding > architecture, machine and emulator for easy of use in the provider code. > > Changed the KVM detection to use the capabilities instead of unique > XML parsing. > > Further, xml_parse_test was extendend to display hypervisor capabilities > and defaults. > > Signed-off-by: Boris Fiuczynski > Signed-off-by: Viktor Mihajlovski > > --- > libxkutil/Makefile.am | 2 + > libxkutil/capability_parsing.c | 556 ++++++++++++++++++++++++++++++++++++++++ > libxkutil/capability_parsing.h | 97 +++++++ > libxkutil/device_parsing.c | 29 --- > libxkutil/device_parsing.h | 2 - > libxkutil/xml_parse_test.c | 201 ++++++++++++++- > 6 files changed, 853 insertions(+), 34 deletions(-) > create mode 100644 libxkutil/capability_parsing.c > create mode 100644 libxkutil/capability_parsing.h > > V2 Changes > + Removed memory leaks > + Removed occurrence of crashes when multiple guests are defined > + Corrected search pattern for default architecture and machine > + Added host CPU architecture parsing > + Extended xml_parse_test with better testing capabilities coverage > + Wrong free on cap guest struct > + Fixed use_kvm method > > diff --git a/libxkutil/Makefile.am b/libxkutil/Makefile.am > index 8d436ad..dd7be55 100644 > --- a/libxkutil/Makefile.am > +++ b/libxkutil/Makefile.am > @@ -7,6 +7,7 @@ noinst_HEADERS = \ > cs_util.h \ > misc_util.h \ > device_parsing.h \ > + capability_parsing.h \ > xmlgen.h \ > infostore.h \ > pool_parsing.h \ > @@ -20,6 +21,7 @@ libxkutil_la_SOURCES = \ > cs_util_instance.c \ > misc_util.c \ > device_parsing.c \ > + capability_parsing.c \ > xmlgen.c \ > infostore.c \ > pool_parsing.c \ > diff --git a/libxkutil/capability_parsing.c b/libxkutil/capability_parsing.c > new file mode 100644 > index 0000000..e3c0f2b > --- /dev/null > +++ b/libxkutil/capability_parsing.c > @@ -0,0 +1,556 @@ > +/* > + * Copyright IBM Corp. 2013 > + * > + * Authors: > + * Boris Fiuczynski > + * > + * 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 Forgot to mention this last time - I went through an exercise where I removed the address here since the above is apparently their old address.... See commit id '391634e2c'. The difference is essentially: - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library. If not, see + * . Also see: http://www.gnu.org/licenses/gpl-howto.html > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +#include "misc_util.h" > +#include "capability_parsing.h" > +#include "xmlgen.h" > +#include "../src/svpc_types.h" > + > +static void cleanup_cap_machine(struct cap_machine *machine) > +{ > + if (machine == NULL) > + return; > + free(machine->name); > + free(machine->canonical_name); > +} > + > +static void cleanup_cap_domain_info(struct cap_domain_info *cgdi) > +{ > + int i; > + if (cgdi == NULL) > + return; > + free(cgdi->emulator); > + free(cgdi->loader); > + for (i = 0; i < cgdi->num_machines; i++) > + cleanup_cap_machine(&cgdi->machines[i]); > + free(cgdi->machines); > +} > + > +static void cleanup_cap_domain(struct cap_domain *cgd) > +{ > + if (cgd == NULL) > + return; > + free(cgd->typestr); > + cleanup_cap_domain_info(&cgd->guest_domain_info); > +} > + > +static void cleanup_cap_arch(struct cap_arch *cga) > +{ > + int i; > + if (cga == NULL) > + return; > + free(cga->name); > + cleanup_cap_domain_info(&cga->default_domain_info); > + for (i = 0; i < cga->num_domains; i++) > + cleanup_cap_domain(&cga->domains[i]); > + free(cga->domains); > +} > + > +static void cleanup_cap_guest(struct cap_guest *cg) > +{ > + if (cg == NULL) > + return; > + free(cg->ostype); > + cleanup_cap_arch(&cg->arch); > +} > + > +static void cleanup_cap_host(struct cap_host *ch) > +{ > + if (ch == NULL) > + return; > + free(ch->cpu_arch); > +} > + > +void cleanup_capabilities(struct capabilities **caps) > +{ > + int i; > + struct capabilities *cap; > + > + if ((caps == NULL) || (*caps == NULL)) > + return; > + > + cap = *caps; > + cleanup_cap_host(&cap->host); > + for (i = 0; i < cap->num_guests; i++) > + cleanup_cap_guest(&cap->guests[i]); > + > + free(cap->guests); > + free(cap); > + *caps = NULL; > +} > + > +static void extend_cap_machines(struct cap_domain_info *cg_domaininfo, > + char *name, char *canonical_name) > +{ > + struct cap_machine *tmp_list = NULL; > + tmp_list = realloc(cg_domaininfo->machines, > + (cg_domaininfo->num_machines + 1) * > + sizeof(struct cap_machine)); > + > + if (tmp_list == NULL) { > + /* Nothing you can do. Just go on. */ > + CU_DEBUG("Could not alloc space for " > + "guest domain info list"); > + return; > + } > + cg_domaininfo->machines = tmp_list; > + > + struct cap_machine *cap_gm = > + &cg_domaininfo->machines[cg_domaininfo->num_machines]; > + cap_gm->name = name; > + cap_gm->canonical_name = canonical_name; > + cg_domaininfo->num_machines++; > +} > + > +static void parse_cap_domain_info(struct cap_domain_info *cg_domaininfo, > + xmlNode *domain_child_node) > +{ > + CU_DEBUG("Capabilities guest domain info element node: %s", > + domain_child_node->name); > + > + if (XSTREQ(domain_child_node->name, "emulator")) { > + cg_domaininfo->emulator = > + get_node_content(domain_child_node); > + } else if (XSTREQ(domain_child_node->name, "loader")) { > + cg_domaininfo->loader = > + get_node_content(domain_child_node); > + } else if (XSTREQ(domain_child_node->name, "machine")) { > + extend_cap_machines(cg_domaininfo, > + get_node_content(domain_child_node), > + get_attr_value(domain_child_node, > + "canonical")); > + } > +} > + > +static void parse_cap_domain(struct cap_domain *cg_domain, > + xmlNode *guest_dom) > +{ > + CU_DEBUG("Capabilities guest domain node: %s", guest_dom->name); > + > + xmlNode *child; > + > + cg_domain->typestr = get_attr_value(guest_dom, "type"); > + > + for (child = guest_dom->children; child != NULL; child = child->next) > + parse_cap_domain_info(&cg_domain->guest_domain_info, child); > +} > + > +static void parse_cap_arch(struct cap_arch *cg_archinfo, > + xmlNode *arch) > +{ > + CU_DEBUG("Capabilities arch node: %s", arch->name); > + > + xmlNode *child; > + > + cg_archinfo->name = get_attr_value(arch, "name"); > + > + for (child = arch->children; child != NULL; child = child->next) { > + if (XSTREQ(child->name, "wordsize")) { > + char *wordsize_str; > + unsigned int wordsize; > + wordsize_str = get_node_content(child); > + /* Default to 0 wordsize if garbage */ > + if (wordsize_str == NULL || > + sscanf(wordsize_str, "%i", &wordsize) != 1) > + wordsize = 0; > + free(wordsize_str); > + cg_archinfo->wordsize = wordsize; > + } else if (XSTREQ(child->name, "domain")) { > + struct cap_domain *tmp_list = NULL; > + tmp_list = realloc(cg_archinfo->domains, > + (cg_archinfo->num_domains + 1) * > + sizeof(struct cap_domain)); > + if (tmp_list == NULL) { > + /* Nothing you can do. Just go on. */ > + CU_DEBUG("Could not alloc space for " > + "guest domain"); > + continue; > + } > + memset(&tmp_list[cg_archinfo->num_domains], > + 0, sizeof(struct cap_domain)); > + cg_archinfo->domains = tmp_list; > + parse_cap_domain(&cg_archinfo-> > + domains[cg_archinfo->num_domains], > + child); > + cg_archinfo->num_domains++; > + } else { > + /* Check for the default domain child nodes */ > + parse_cap_domain_info(&cg_archinfo->default_domain_info, > + child); > + } > + } > +} > + > +static void parse_cap_guests(xmlNodeSet *nsv, struct cap_guest *cap_guests) > +{ > + xmlNode **nodes = nsv->nodeTab; > + xmlNode *child; > + int numGuestNodes = nsv->nodeNr; > + int i; > + > + for (i = 0; i < numGuestNodes; i++) { > + for (child = nodes[i]->children; child != NULL; > + child = child->next) { > + if (XSTREQ(child->name, "os_type")) { > + STRPROP((&cap_guests[i]), ostype, child); > + } else if (XSTREQ(child->name, "arch")) { > + parse_cap_arch(&cap_guests[i].arch, child); > + } > + } > + } > +} > + > +static int parse_cap_host_cpu(struct cap_host *cap_host, xmlNode *cpu) > +{ > + xmlNode *child; > + > + for (child = cpu->children; child != NULL; child = child->next) { > + if (XSTREQ(child->name, "arch")) { > + cap_host->cpu_arch = get_node_content(child); > + if (cap_host->cpu_arch != NULL) > + return 1; /* success - host arch node found */ > + else { > + CU_DEBUG("Host architecture is not defined"); > + break; > + } > + } > + } > + return 0; /* error - no arch node or empty arch node */ > +} > + > +static int parse_cap_host(xmlNodeSet *nsv, struct cap_host *cap_host) > +{ > + xmlNode **nodes = nsv->nodeTab; > + xmlNode *child; > + if (nsv->nodeNr < 1) > + return 0; /* error no node below host */ > + > + for (child = nodes[0]->children; child != NULL; child = child->next) { > + if (XSTREQ(child->name, "cpu")) > + return parse_cap_host_cpu(cap_host, child); > + } > + return 0; /* error - no cpu node */ > +} > + > +static void compare_copy_domain_info_machines( > + struct cap_domain_info *def_gdomi, > + struct cap_domain_info *cap_gadomi) > +{ > + int i,j; > + int org_l = cap_gadomi->num_machines; > + char *cp_name = NULL; > + char *cp_canonical_name = NULL; > + bool found; > + > + for (i = 0; i < def_gdomi->num_machines; i++) { > + found = false; > + for (j = 0; j < org_l; j++) { > + if (STREQC(def_gdomi->machines[i].name, > + cap_gadomi->machines[j].name)) { > + found = true; > + continue; > + /* found match => check next default */ > + } > + } > + if (!found) { /* no match => insert default */ > + cp_name = NULL; > + cp_canonical_name = NULL; > + if (def_gdomi->machines[i].name != NULL) > + cp_name = strdup(def_gdomi->machines[i].name); > + if (def_gdomi->machines[i].canonical_name != NULL) > + cp_canonical_name = > + strdup(def_gdomi-> > + machines[i].canonical_name); > + > + extend_cap_machines(cap_gadomi, > + cp_name, > + cp_canonical_name); > + } > + } > +} > + > +static void extend_defaults_cap_guests(struct capabilities *caps) > +{ > + struct cap_arch *cap_garch; > + struct cap_domain_info *cap_gadomi; > + struct cap_domain_info *def_gdomi; > + int i,j; > + > + if (caps == NULL) > + return; > + > + for (i = 0; i < caps->num_guests; i++) { > + cap_garch = &caps->guests[i].arch; > + def_gdomi = &cap_garch->default_domain_info; > + > + for (j = 0; j < cap_garch->num_domains; j++) { > + /* compare guest_domain_info */ > + cap_gadomi = &cap_garch->domains[j].guest_domain_info; > + if (cap_gadomi->emulator == NULL && > + def_gdomi->emulator != NULL) > + cap_gadomi->emulator = > + strdup(def_gdomi->emulator); > + if (cap_gadomi->loader == NULL && > + def_gdomi->loader != NULL) > + cap_gadomi->loader = strdup(def_gdomi->loader); > + > + compare_copy_domain_info_machines(def_gdomi, > + cap_gadomi); > + } > + } > +} > + > +static int _get_capabilities(const char *xml, struct capabilities *caps) > +{ > + int len; > + int ret = 0; > + > + xmlDoc *xmldoc = NULL; > + xmlXPathContext *xpathctx = NULL; > + xmlXPathObject *xpathobj = NULL; > + const xmlChar *xpathhoststr = (xmlChar *)"//capabilities//host"; > + const xmlChar *xpathgueststr = (xmlChar *)"//capabilities//guest"; > + xmlNodeSet *nsv; > + > + len = strlen(xml) + 1; > + > + if ((xmldoc = xmlParseMemory(xml, len)) == NULL) > + goto err; > + > + if ((xpathctx = xmlXPathNewContext(xmldoc)) == NULL) > + goto err; > + > + /* host node */ > + if ((xpathobj = xmlXPathEvalExpression(xpathhoststr, xpathctx)) == NULL) > + goto err; > + if (xmlXPathNodeSetIsEmpty(xpathobj->nodesetval)) { > + CU_DEBUG("No capabilities host node found!"); > + goto err; > + } > + > + nsv = xpathobj->nodesetval; > + if (!parse_cap_host(nsv, &caps->host)) > + goto err; > + xmlXPathFreeObject(xpathobj); > + > + /* all guest nodes */ > + if ((xpathobj = xmlXPathEvalExpression(xpathgueststr, xpathctx)) == NULL) > + goto err; > + if (xmlXPathNodeSetIsEmpty(xpathobj->nodesetval)) { > + CU_DEBUG("No capabilities guest nodes found!"); > + goto err; > + } > + > + nsv = xpathobj->nodesetval; > + caps->guests = calloc(nsv->nodeNr, sizeof(struct cap_guest)); > + if (caps->guests == NULL) > + goto err; > + caps->num_guests = nsv->nodeNr; > + > + parse_cap_guests(nsv, caps->guests); > + extend_defaults_cap_guests(caps); > + ret = 1; > + > + err: > + xmlXPathFreeObject(xpathobj); > + xmlXPathFreeContext(xpathctx); > + xmlFreeDoc(xmldoc); > + return ret; > +} > + > +int get_caps_from_xml(const char *xml, struct capabilities **caps) > +{ > + CU_DEBUG("In get_caps_from_xml"); > + > + free(*caps); > + *caps = calloc(1, sizeof(struct capabilities)); > + if (*caps == NULL) > + goto err; > + > + if (_get_capabilities(xml, *caps) == 0) > + goto err; > + > + return 1; > + > + err: > + free(*caps); > + *caps = NULL; > + return 0; > +} > + > +int get_capabilities(virConnectPtr conn, struct capabilities **caps) > +{ > + char *caps_xml = NULL; > + int ret = 0; > + > + if (conn == NULL) { > + CU_DEBUG("Unable to connect to libvirt."); > + return 0; > + } > + > + caps_xml = virConnectGetCapabilities(conn); > + > + if (caps_xml == NULL) { > + CU_DEBUG("Unable to get capabilities xml."); > + return 0; > + } > + > + ret = get_caps_from_xml(caps_xml, caps); > + > + free(caps_xml); > + > + return ret; > +} > + > +struct cap_domain_info *findDomainInfo(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type) > +{ > + int i,j; > + struct cap_arch *ar; > + > + for (i = 0; i < caps->num_guests; i++) { > + if (os_type == NULL || > + STREQC(caps->guests[i].ostype, os_type)) { > + ar = &caps->guests[i].arch; > + if (arch == NULL || STREQC(ar->name,arch)) > + for (j = 0; j < ar->num_domains; j++) > + if (domain_type == NULL || > + STREQC(ar->domains[j].typestr, > + domain_type)) > + return &ar->domains[j]. > + guest_domain_info; > + } > + } > + return NULL; > +} > + > +static char *_findDefArch(struct capabilities *caps, > + const char *os_type, > + const char *host_arch) > +{ > + char *ret = NULL; > + int i; > + > + if (os_type == NULL) > + return NULL; Technically unnecessary... See comment below > + > + for (i = 0; i < caps->num_guests; i++) I know there's just one statement inside, but consider using {} for consistency and on the off chance someone misses this in the future. > + if (STREQC(caps->guests[i].ostype, os_type) && > + (host_arch == NULL || (host_arch != NULL && > + STREQC(caps->guests[i].arch.name, host_arch)))) { > + ret = caps->guests[i].arch.name; > + break; > + } > + return ret; > +} > + > +char *get_default_arch(struct capabilities *caps, > + const char *os_type) > +{ > + char *ret = NULL; > + > + if (caps != NULL) { > + if (os_type != NULL) { Checks could be combined - reducing indention a bit. > + /* search first guest matching os_type and host arch */ > + ret = _findDefArch(caps, os_type, caps->host.cpu_arch); > + if (ret== NULL) /* search first matching guest */ Need space ^ > + ret = _findDefArch(caps, os_type, NULL); Since this is the only caller to _findDefArch and we know "caps != NULL && os_type != NULL", then the check in _findDefArch() becomes unnecessary > + } > + } > + return ret; > +} > + > +char *get_default_machine( > + struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type) > +{ > + char *ret = NULL; > + struct cap_domain_info *di; > + > + if (caps != NULL) { > + di = findDomainInfo(caps, os_type, arch, domain_type); > + if (di != NULL && di->num_machines > 0) { > + ret = di->machines[0].canonical_name; > + if (ret == NULL) { > + ret = di->machines[0].name; > + } Alternatively ret = di->machines[0].canonical_name ? di->machines[0].canonical_name : di->machines[0].name; > + } > + } > + return ret; > +} > + > +char *get_default_emulator(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type) > +{ > + char *ret = NULL; > + struct cap_domain_info *di; > + > + if (caps != NULL) { > + di = findDomainInfo(caps, os_type, arch, domain_type); > + if (di != NULL) > + ret = di->emulator; > + } > + return ret; > +} > + > +bool use_kvm(struct capabilities *caps) { > + if (host_supports_kvm(caps) && !get_disable_kvm()) > + return true; > + else else is unnecessary > + return false; > +} > + > +bool host_supports_kvm(struct capabilities *caps) > +{ > + bool kvm = false; > + if (caps != NULL) Again consider {} here so for consistency and prevention... > + if (findDomainInfo(caps, NULL, NULL, "kvm") != NULL) > + kvm = true; > + return kvm; > +} > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ > diff --git a/libxkutil/capability_parsing.h b/libxkutil/capability_parsing.h > new file mode 100644 > index 0000000..d258f62 > --- /dev/null > +++ b/libxkutil/capability_parsing.h > @@ -0,0 +1,97 @@ > +/* > + * Copyright IBM Corp. 2013 > + * > + * Authors: > + * Boris Fiuczynski > + * > + * 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 Adjust the info here too. > + */ > +#ifndef __CAPABILITY_PARSING_H > +#define __CAPABILITY_PARSING_H > + > +#include > +#include > + > +struct cap_host { > + char *cpu_arch; > +}; > + > +struct cap_machine { > + char *name; > + char *canonical_name; > +}; > + > +struct cap_domain_info { > + char *emulator; > + char *loader; > + int num_machines; > + struct cap_machine *machines; > +}; > + > +struct cap_domain { > + char *typestr; > + struct cap_domain_info guest_domain_info; > +}; > + > +struct cap_arch { > + char *name; > + unsigned int wordsize; > + struct cap_domain_info default_domain_info; > + int num_domains; > + struct cap_domain *domains; > +}; > + > +struct cap_guest { > + char *ostype; > + struct cap_arch arch; > +}; > + > +struct capabilities { > + struct cap_host host; > + int num_guests; > + struct cap_guest *guests; > +}; > + > +int get_caps_from_xml(const char *xml, struct capabilities **caps); > +int get_capabilities(virConnectPtr conn, struct capabilities **caps); > +char *get_default_arch(struct capabilities *caps, > + const char *os_type); > +char *get_default_machine(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type); > +char *get_default_emulator(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type); > +struct cap_domain_info *findDomainInfo(struct capabilities *caps, > + const char *os_type, > + const char *arch, > + const char *domain_type); > +bool use_kvm(struct capabilities *caps); > +bool host_supports_kvm(struct capabilities *caps); > +void cleanup_capabilities(struct capabilities **caps); > + > +#endif > + > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index df7a87a..449f51c 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -397,35 +397,6 @@ err: > return 0; > } > > -bool has_kvm_domain_type(xmlNodePtr node) > -{ > - xmlNodePtr child = NULL; > - char *type = NULL; > - bool ret = false; > - > - child = node->children; > - while (child != NULL) { > - if (XSTREQ(child->name, "domain")) { > - type = get_attr_value(child, "type"); > - if (XSTREQ(type, "kvm")) { > - ret = true; > - goto out; > - } > - } > - > - if (has_kvm_domain_type(child) == 1) { > - ret = true; > - goto out; > - } > - > - child = child->next; > - } > - > - out: > - free(type); > - return ret; > -} > - > static int parse_net_device(xmlNode *inode, struct virt_device **vdevs) > { > struct virt_device *vdev = NULL; > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 379d48c..a39e881 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -223,8 +223,6 @@ int attach_device(virDomainPtr dom, struct virt_device *dev); > int detach_device(virDomainPtr dom, struct virt_device *dev); > int change_device(virDomainPtr dom, struct virt_device *dev); > > -bool has_kvm_domain_type(xmlNodePtr node); > - > #define XSTREQ(x, y) (STREQ((char *)x, y)) > #define STRPROP(d, p, n) (d->p = get_node_content(n)) > > diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c > index 384593d..de2c88a 100644 > --- a/libxkutil/xml_parse_test.c > +++ b/libxkutil/xml_parse_test.c > @@ -6,6 +6,7 @@ > #include > > #include "device_parsing.h" > +#include "capability_parsing.h" > #include "xmlgen.h" > > static void print_value(FILE *d, const char *name, const char *val) > @@ -25,6 +26,36 @@ static void print_u32(FILE *d, const char *name, uint32_t val) > } > #endif > > +static char *get_ostype(struct domain *dom) > +{ > + if (dom->type == DOMAIN_XENPV) { > + return dom->os_info.pv.type; > + } else if ((dom->type == DOMAIN_XENFV) || > + (dom->type == DOMAIN_KVM) || > + (dom->type == DOMAIN_QEMU)) { > + return dom->os_info.fv.type; > + } else if (dom->type == DOMAIN_LXC) { > + return dom->os_info.lxc.type; > + } else { > + return NULL; > + } > +} > + > +static char *get_domaintype(struct domain *dom) > +{ > + if (dom->type == DOMAIN_XENPV || dom->type == DOMAIN_XENFV) { > + return "xen"; > + } else if (dom->type == DOMAIN_KVM) { > + return "kvm"; > + } else if (dom->type == DOMAIN_QEMU) { > + return "qemu"; > + } else if (dom->type == DOMAIN_LXC) { > + return "lxc"; > + } else { > + return NULL; > + } > +} > + > static void print_os(struct domain *dom, > FILE *d) > { > @@ -183,6 +214,98 @@ static char *read_from_file(FILE *file) > return xml; > } > > +static void print_cap_domain_info(struct cap_domain_info *capgdiinfo, > + FILE *d) > +{ > + struct cap_machine capgminfo; > + int i; > + > + if (capgdiinfo==NULL) NIT: No spacing (e.g. " == ") > + return; > + > + if (capgdiinfo->emulator!=NULL) Ditto > + print_value(d, " Emulator", capgdiinfo->emulator); > + if (capgdiinfo->loader!=NULL) Ditto The remainder seemed fine. John > + print_value(d, " Loader", capgdiinfo->loader); > + for (i = 0; i < capgdiinfo->num_machines; i++) { > + capgminfo = capgdiinfo->machines[i]; > + fprintf(d, " Machine name : %-15s canonical name : %s\n", > + capgminfo.name, capgminfo.canonical_name); > + } > + fprintf(d, "\n"); > +} > + > +static void print_cap_domains(struct cap_arch caparchinfo, > + FILE *d) > +{ > + struct cap_domain capgdinfo; > + int i; > + for (i = 0; i < caparchinfo.num_domains; i++) { > + capgdinfo = caparchinfo.domains[i]; > + print_value(d, " Type", capgdinfo.typestr); > + print_cap_domain_info(&capgdinfo.guest_domain_info, d); > + } > +} > + > +static void print_cap_arch(struct cap_arch caparchinfo, > + FILE *d) > +{ > + print_value(d, " Arch name", caparchinfo.name); > + fprintf(d, " Arch wordsize : %i\n", caparchinfo.wordsize); > + fprintf(d, "\n -- Default guest domain settings --\n"); > + print_cap_domain_info(&caparchinfo.default_domain_info, d); > + fprintf(d, " -- Guest domains (%i) --\n", caparchinfo.num_domains); > + print_cap_domains(caparchinfo, d); > +} > + > +static void print_cap_guest(struct cap_guest *capginfo, > + FILE *d) > +{ > + print_value(d, "Guest OS type", capginfo->ostype); > + print_cap_arch(capginfo->arch, d); > +} > + > +static void print_cap_host(struct cap_host *caphinfo, > + FILE *d) > +{ > + print_value(d, "Host CPU architecture", caphinfo->cpu_arch); > +} > + > +static void print_capabilities(struct capabilities *capsinfo, > + FILE *d) > +{ > + int i; > + fprintf(d, "\n### Capabilities ###\n"); > + fprintf(d, "-- Host --\n"); > + print_cap_host(&capsinfo->host, d); > + fprintf(d, "\n-- Guest (%i) --\n", capsinfo->num_guests); > + for (i = 0; i < capsinfo->num_guests; i++) > + print_cap_guest(&capsinfo->guests[i], d); > +} > + > +static int capinfo_for_dom(const char *uri, > + struct domain *dominfo, > + struct capabilities **capsinfo) > +{ > + virConnectPtr conn = NULL; > + char *caps_xml = NULL; > + int ret = 0; > + > + conn = virConnectOpen(uri); > + if (conn == NULL) { > + printf("Unable to connect to libvirt\n"); > + goto out; > + } > + > + ret = get_capabilities(conn, capsinfo); > + > + out: > + free(caps_xml); > + virConnectClose(conn); > + > + return ret; > +} > + > static int dominfo_from_dom(const char *uri, > const char *domain, > struct domain **d) > @@ -246,12 +369,13 @@ static int dominfo_from_file(const char *fname, struct domain **d) > static void usage(void) > { > printf("xml_parse_test -f [FILE | -] [--xml]\n" > - "xml_parse_test -d domain [--uri URI] [--xml]\n" > + "xml_parse_test -d domain [--uri URI] [--xml] [--cap]\n" > "\n" > "-f,--file FILE Parse domain XML from file (or stdin if -)\n" > "-d,--domain DOM Display dominfo for a domain from libvirt\n" > "-u,--uri URI Connect to libvirt with URI\n" > "-x,--xml Dump generated XML instead of summary\n" > + "-c,--cap Display the libvirt default capability values for the specified domain\n" > "-h,--help Display this help message\n"); > } > > @@ -262,7 +386,10 @@ int main(int argc, char **argv) > char *uri = "xen"; > char *file = NULL; > bool xml = false; > + bool cap = false; > struct domain *dominfo = NULL; > + struct capabilities *capsinfo = NULL; > + struct cap_domain_info *capgdinfo = NULL; > int ret; > > static struct option lopts[] = { > @@ -270,13 +397,14 @@ int main(int argc, char **argv) > {"uri", 1, 0, 'u'}, > {"xml", 0, 0, 'x'}, > {"file", 1, 0, 'f'}, > + {"cap", 0, 0, 'c'}, > {"help", 0, 0, 'h'}, > {0, 0, 0, 0}}; > > while (1) { > int optidx = 0; > > - c = getopt_long(argc, argv, "d:u:f:xh", lopts, &optidx); > + c = getopt_long(argc, argv, "d:u:f:xch", lopts, &optidx); > if (c == -1) > break; > > @@ -297,11 +425,14 @@ int main(int argc, char **argv) > xml = true; > break; > > + case 'c': > + cap = true; > + break; > + > case '?': > case 'h': > usage(); > return c == '?'; > - > }; > } > > @@ -326,6 +457,70 @@ int main(int argc, char **argv) > print_devices(dominfo, stdout); > } > > + if (cap && file == NULL) { > + ret = capinfo_for_dom(uri, dominfo, &capsinfo); > + if (ret == 0) { > + printf("Unable to get capsinfo\n"); > + return 3; > + } else { > + print_capabilities(capsinfo, stdout); > + const char *os_type = get_ostype(dominfo); > + const char *dom_type = get_domaintype(dominfo); > + const char *def_arch = get_default_arch(capsinfo, os_type); > + > + fprintf(stdout, "-- KVM is used: %s\n\n", (use_kvm(capsinfo)?"true":"false")); > + fprintf(stdout, "-- For all following default OS type=%s\n", os_type); > + fprintf(stdout, "-- Default Arch : %s\n", def_arch); > + > + fprintf(stdout, > + "-- Default Machine for arch=NULL : %s\n", > + get_default_machine(capsinfo, os_type, NULL, NULL)); > + fprintf(stdout, > + "-- Default Machine for arch=%s and domain type=NULL : %s\n", > + def_arch, > + get_default_machine(capsinfo, os_type, def_arch, NULL)); > + fprintf(stdout, > + "-- Default Machine for arch=%s and domain type=%s : %s\n", > + def_arch, dom_type, > + get_default_machine(capsinfo, os_type, def_arch, dom_type)); > + fprintf(stdout, > + "-- Default Machine for arch=NULL and domain type=%s : %s\n", > + dom_type, > + get_default_machine(capsinfo, os_type, NULL, dom_type)); > + > + fprintf(stdout, > + "-- Default Emulator for arch=NULL : %s\n", > + get_default_emulator(capsinfo, os_type, NULL, NULL)); > + fprintf(stdout, > + "-- Default Emulator for arch=%s and domain type=NULL : %s\n", > + def_arch, > + get_default_emulator(capsinfo, os_type, def_arch, NULL)); > + fprintf(stdout, > + "-- Default Emulator for arch=%s and domain type=%s : %s\n", > + def_arch, dom_type, > + get_default_emulator(capsinfo, os_type, def_arch, dom_type)); > + fprintf(stdout, > + "-- Default Emulator for arch=NULL and domain type=%s : %s\n", > + dom_type, > + get_default_emulator(capsinfo, os_type, NULL, dom_type)); > + > + fprintf(stdout, "\n-- Default Domain Search for: \n" > + "guest type=hvm - guest arch=* - guest domain type=kvm\n"); > + capgdinfo = findDomainInfo(capsinfo, "hvm", NULL, "kvm"); > + print_cap_domain_info(capgdinfo, stdout); > + > + fprintf(stdout, "-- Default Domain Search for: \n" > + "guest type=* - guest arch=* - guest domain type=*\n"); > + capgdinfo = findDomainInfo(capsinfo, NULL, NULL, NULL); > + print_cap_domain_info(capgdinfo, stdout); > + > + cleanup_capabilities(&capsinfo); > + } > + } else if (cap) { > + printf("Need a data source (--domain) to get default capabilities\n"); > + return 4; > + } > + > return 0; > } > > From jferlan at redhat.com Thu Aug 29 20:41:36 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 29 Aug 2013 16:41:36 -0400 Subject: [Libvirt-cim] [PATCHv2 5/5] VSSM: Set default values based on libvirt capabilities on DefineSystem calls In-Reply-To: <1377789533-8945-6-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1377789533-8945-6-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <521FB200.5080207@redhat.com> On 08/29/2013 11:18 AM, Viktor Mihajlovski wrote: > From: Boris Fiuczynski > > In the DefineSystem call the architecture, machine and emulator for KVM are set > to the hypervisor-specific default values if they did not get provided. > This now allows architecture based decision making in the CIM providers to > work for all platforms. > > Signed-off-by: Boris Fiuczynski > Reviewed-by: Viktor Mihajlovski > > --- > src/Virt_VirtualSystemManagementService.c | 161 ++++++++++++++--------------- > 1 file changed, 78 insertions(+), 83 deletions(-) > > V2 Changes > + Removed memory leaks > + Restricted setting machine and emulator defaults to KVM/QEMU cases > Two NITs below, but ACK in any case, John > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 301f046..53b9691 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -35,6 +35,7 @@ > #include "cs_util.h" > #include "misc_util.h" > #include "device_parsing.h" > +#include "capability_parsing.h" > #include "xmlgen.h" > > #include > @@ -388,59 +389,6 @@ static bool fv_set_emulator(struct domain *domain, > return true; > } > > -static bool system_has_kvm(const char *pfx) > -{ > - CMPIStatus s; > - virConnectPtr conn = NULL; > - char *caps = NULL; > - bool disable_kvm = get_disable_kvm(); > - xmlDocPtr doc = NULL; > - xmlNodePtr node = NULL; > - int len; > - bool kvm = false; > - > - /* sometimes disable KVM to avoid problem in nested KVM */ > - if (disable_kvm) { > - CU_DEBUG("Enter disable kvm mode!"); > - goto out; > - } > - > - conn = connect_by_classname(_BROKER, pfx, &s); > - if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { > - goto out; > - } > - > - caps = virConnectGetCapabilities(conn); > - if (caps != NULL) { > - len = strlen(caps) + 1; > - > - doc = xmlParseMemory(caps, len); > - if (doc == NULL) { > - CU_DEBUG("xmlParseMemory() call failed!"); > - goto out; > - } > - > - node = xmlDocGetRootElement(doc); > - if (node == NULL) { > - CU_DEBUG("xmlDocGetRootElement() call failed!"); > - goto out; > - } > - > - if (has_kvm_domain_type(node)) { > - CU_DEBUG("The system support kvm!"); > - kvm = true; > - } > - } > - > -out: > - free(caps); > - free(doc); > - > - virConnectClose(conn); > - > - return kvm; > -} > - > static int bootord_vssd_to_domain(CMPIInstance *inst, > struct domain *domain) > { > @@ -511,53 +459,91 @@ static int bootord_vssd_to_domain(CMPIInstance *inst, > > static int fv_vssd_to_domain(CMPIInstance *inst, > struct domain *domain, > - const char *pfx) > + const char *pfx, > + virConnectPtr conn) > { > - int ret; > + int ret = 1; > + int retr; > const char *val; > + const char *domtype; Could have just initialized == NULL; here... > + const char *ostype = "hvm"; > + struct capabilities *capsinfo = NULL; > + > + get_capabilities(conn, &capsinfo); > > if (STREQC(pfx, "KVM")) { > - if (system_has_kvm(pfx)) > + if (use_kvm(capsinfo)) { > domain->type = DOMAIN_KVM; > - else > + domtype = "kvm"; > + } else { > domain->type = DOMAIN_QEMU; > + domtype = "qemu"; > + } > } else if (STREQC(pfx, "Xen")) { > domain->type = DOMAIN_XENFV; > + domtype = NULL; Thus not needing this one... nor anyone else in the future forgetting to set/initialize it... > } else { > CU_DEBUG("Unknown fullvirt domain type: %s", pfx); > - return 0; > + ret = 0; > + goto out; > } > > - ret = bootord_vssd_to_domain(inst, domain); > - if (ret != 1) > - return 0; > - > - ret = cu_get_str_prop(inst, "Emulator", &val); > - if (ret != CMPI_RC_OK) > - val = NULL; > - else if (disk_type_from_file(val) == DISK_UNKNOWN) { > - CU_DEBUG("Emulator path does not exist: %s", val); > - return 0; > + retr = bootord_vssd_to_domain(inst, domain); > + if (retr != 1) { > + ret = 0; > + goto out; > } > > - if (!fv_set_emulator(domain, val)) > - return 0; > - > free(domain->os_info.fv.arch); > - ret = cu_get_str_prop(inst, "Arch", &val); > - if (ret == CMPI_RC_OK) > + retr = cu_get_str_prop(inst, "Arch", &val); > + if (retr != CMPI_RC_OK) { > + if (capsinfo != NULL) { /* set default */ > + val = get_default_arch(capsinfo, ostype); > + CU_DEBUG("Set Arch to default: %s", val); > + } else > + val = NULL; > + } > + if (val != NULL) > domain->os_info.fv.arch = strdup(val); > - else > - domain->os_info.fv.arch = NULL; > > free(domain->os_info.fv.machine); > - ret = cu_get_str_prop(inst, "Machine", &val); > - if (ret == CMPI_RC_OK) > + retr = cu_get_str_prop(inst, "Machine", &val); > + if (retr != CMPI_RC_OK) { > + if (capsinfo != NULL && domtype != NULL) { /* set default */ > + val = get_default_machine(capsinfo, ostype, > + domain->os_info.fv.arch, > + domtype); > + CU_DEBUG("Set Machine to default: %s", val); > + } else > + val = NULL; > + } > + if (val != NULL) > domain->os_info.fv.machine = strdup(val); > - else > - domain->os_info.fv.machine = NULL; > > - return 1; > + retr = cu_get_str_prop(inst, "Emulator", &val); > + if (retr != CMPI_RC_OK) { > + if (capsinfo != NULL && domtype != NULL) { /* set default */ > + val = get_default_emulator(capsinfo, ostype, > + domain->os_info.fv.arch, > + domtype); > + CU_DEBUG("Set Emulator to default: %s", val); > + } else > + val = NULL; > + } > + if (val != NULL && disk_type_from_file(val) == DISK_UNKNOWN) { > + CU_DEBUG("Emulator path does not exist: %s", val); > + ret = 0; > + goto out; > + } > + > + if (!fv_set_emulator(domain, val)) { > + ret = 0; > + goto out; > + } > + > + out: > + cleanup_capabilities(&capsinfo); > + return ret; > } > > static int lxc_vssd_to_domain(CMPIInstance *inst, > @@ -663,6 +649,8 @@ static int vssd_to_domain(CMPIInstance *inst, > bool bool_val; > bool fullvirt; > CMPIObjectPath *opathp = NULL; > + virConnectPtr conn = NULL; > + CMPIStatus s = { CMPI_RC_OK, NULL }; > > > opathp = CMGetObjectPath(inst, NULL); > @@ -748,9 +736,16 @@ static int vssd_to_domain(CMPIInstance *inst, > } > } > > - if (fullvirt || STREQC(pfx, "KVM")) > - ret = fv_vssd_to_domain(inst, domain, pfx); > - else if (STREQC(pfx, "Xen")) > + if (fullvirt || STREQC(pfx, "KVM")) { > + conn = connect_by_classname(_BROKER, cn, &s); > + if (conn == NULL || (s.rc != CMPI_RC_OK)) { > + CU_DEBUG("libvirt connection failed"); Since you're not returning CMPIStatus, then really no need to check s.rc although it's no big deal either as conn will be NULL and I see no way for conn to be non-NULL and s.rc != CMPI_RC_OK. If there were, then you'd have to close the connection... > + ret = 0; > + goto out; > + } > + ret = fv_vssd_to_domain(inst, domain, pfx, conn); > + virConnectClose(conn); > + } else if (STREQC(pfx, "Xen")) > ret = xenpv_vssd_to_domain(inst, domain); > else if (STREQC(pfx, "LXC")) > ret = lxc_vssd_to_domain(inst, domain); > From jferlan at redhat.com Thu Aug 29 20:52:28 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 29 Aug 2013 16:52:28 -0400 Subject: [Libvirt-cim] [PATCHv2 0/5] Initial Enablement of S390 In-Reply-To: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <521FB48C.3000003@redhat.com> On 08/29/2013 11:18 AM, Viktor Mihajlovski wrote: > The current libvirt-cim implementation makes some assumptions > that are only true for x86 architectures. As we want to > enable libvirt-cim for s390 we need to makes sure that > valid libvirt guest definitions are being built for that > architecture while not breaking the existing implementation. > > Patch 1 fixes potential memory access problems. > > Patches 2 and 3 introduce two new properties arch and machine, > effectively a pass-through of the underlying libvirt > properties, for the necessary distinction between x86 and > other guests, and suppress the default framebuffer for > s390. > > Patches 4 and 5 make sure that a minimal SVPC guest definition > (VSSD and RASD) will result in a correct libvirt guest definition > for the current hypervisor. > > Boris Fiuczynski (2): > libxkutil: Provide easy access to the libvirt capabilities > VSSM: Set default values based on libvirt capabilities on > DefineSystem calls > > Viktor Mihajlovski (3): > libxkutil: Improve domain.os_info cleanup > VSSD: Add properties for arch and machine > S390: Avoid the generation of default input and graphics > > libxkutil/Makefile.am | 2 + > libxkutil/capability_parsing.c | 556 +++++++++++++++++++++++++++++ > libxkutil/capability_parsing.h | 97 +++++ > libxkutil/device_parsing.c | 114 +++--- > libxkutil/device_parsing.h | 4 +- > libxkutil/xml_parse_test.c | 201 ++++++++++- > libxkutil/xmlgen.c | 6 + > schema/VSSD.mof | 6 + > src/Virt_VSSD.c | 9 + > src/Virt_VirtualSystemManagementService.c | 165 +++++---- > 10 files changed, 1033 insertions(+), 127 deletions(-) > create mode 100644 libxkutil/capability_parsing.c > create mode 100644 libxkutil/capability_parsing.h > > > V2 Changes > # Split original patch 1 into 2 patches (fix, new feature), otherwise unchanged > # Patch 3 also considers QEMU domains now, was KVM only > # Patches 4 and 5 address memory leaks and overwrites > # cimtest run completes without regressions on x86 > > Things look good - cimtest and coverity tests both were happy. Since I had already ACK'd patch 1 which is now patch 1 & 2, consider the ACK still valid. Also the old patch 2 ACK is still valid even with the self find of the missing qemu check. I posted nits/questions separately about patches 4 & 5. Since I believe you still need me to push, feel free to post either just a set of diffs for me to squash into or a v3. Is there a desire to get this into a RHEL release eventually or into the "next" RHEL release? I'd rather let this "soak" a while and then work on getting a complete libvirt-cim into a future 6.n release over what I have to do now which is patch 0.6.1 with 0.6.3 based patches... John From mihajlov at linux.vnet.ibm.com Fri Aug 30 11:29:11 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 30 Aug 2013 13:29:11 +0200 Subject: [Libvirt-cim] [PATCHv2 4/5] libxkutil: Provide easy access to the libvirt capabilities In-Reply-To: <521FAEF1.9010602@redhat.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1377789533-8945-5-git-send-email-mihajlov@linux.vnet.ibm.com> <521FAEF1.9010602@redhat.com> Message-ID: <52208207.8010706@linux.vnet.ibm.com> Hi John, please try to squash in the following patch, courtesy of Boris -- diff --git a/libxkutil/capability_parsing.c b/libxkutil/capability_parsing.c index e3c0f2b..2acd45b 100644 --- a/libxkutil/capability_parsing.c +++ b/libxkutil/capability_parsing.c @@ -15,8 +15,8 @@ * 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 + * License along with this library. If not, see + * . */ #include #include @@ -464,16 +464,14 @@ static char *_findDefArch(struct capabilities *caps, char *ret = NULL; int i; - if (os_type == NULL) - return NULL; - - for (i = 0; i < caps->num_guests; i++) + for (i = 0; i < caps->num_guests; i++) { if (STREQC(caps->guests[i].ostype, os_type) && (host_arch == NULL || (host_arch != NULL && STREQC(caps->guests[i].arch.name, host_arch)))) { ret = caps->guests[i].arch.name; break; } + } return ret; } @@ -482,13 +480,11 @@ char *get_default_arch(struct capabilities *caps, { char *ret = NULL; - if (caps != NULL) { - if (os_type != NULL) { - /* search first guest matching os_type and host arch */ - ret = _findDefArch(caps, os_type, caps->host.cpu_arch); - if (ret== NULL) /* search first matching guest */ - ret = _findDefArch(caps, os_type, NULL); - } + if (caps != NULL && os_type != NULL) { + /* search first guest matching os_type and host arch */ + ret = _findDefArch(caps, os_type, caps->host.cpu_arch); + if (ret == NULL) /* search first matching guest */ + ret = _findDefArch(caps, os_type, NULL); } return ret; } @@ -505,10 +501,9 @@ char *get_default_machine( if (caps != NULL) { di = findDomainInfo(caps, os_type, arch, domain_type); if (di != NULL && di->num_machines > 0) { - ret = di->machines[0].canonical_name; - if (ret == NULL) { - ret = di->machines[0].name; - } + ret = di->machines[0].canonical_name ? + di->machines[0].canonical_name : + di->machines[0].name; } } return ret; @@ -533,16 +528,16 @@ char *get_default_emulator(struct capabilities *caps, bool use_kvm(struct capabilities *caps) { if (host_supports_kvm(caps) && !get_disable_kvm()) return true; - else - return false; + return false; } bool host_supports_kvm(struct capabilities *caps) { bool kvm = false; - if (caps != NULL) + if (caps != NULL) { if (findDomainInfo(caps, NULL, NULL, "kvm") != NULL) kvm = true; + } return kvm; } /* diff --git a/libxkutil/capability_parsing.h b/libxkutil/capability_parsing.h index d258f62..41a4933 100644 --- a/libxkutil/capability_parsing.h +++ b/libxkutil/capability_parsing.h @@ -15,8 +15,8 @@ * 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 + * License along with this library. If not, see + * . */ #ifndef __CAPABILITY_PARSING_H #define __CAPABILITY_PARSING_H diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c index de2c88a..af5e508 100644 --- a/libxkutil/xml_parse_test.c +++ b/libxkutil/xml_parse_test.c @@ -220,12 +220,12 @@ static void print_cap_domain_info(struct cap_domain_info *capgdiinfo, struct cap_machine capgminfo; int i; - if (capgdiinfo==NULL) + if (capgdiinfo == NULL) return; - if (capgdiinfo->emulator!=NULL) + if (capgdiinfo->emulator != NULL) print_value(d, " Emulator", capgdiinfo->emulator); - if (capgdiinfo->loader!=NULL) + if (capgdiinfo->loader != NULL) print_value(d, " Loader", capgdiinfo->loader); for (i = 0; i < capgdiinfo->num_machines; i++) { capgminfo = capgdiinfo->machines[i]; Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Fri Aug 30 11:31:43 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 30 Aug 2013 13:31:43 +0200 Subject: [Libvirt-cim] [PATCHv2 5/5] VSSM: Set default values based on libvirt capabilities on DefineSystem calls In-Reply-To: <521FB200.5080207@redhat.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1377789533-8945-6-git-send-email-mihajlov@linux.vnet.ibm.com> <521FB200.5080207@redhat.com> Message-ID: <5220829F.7090508@linux.vnet.ibm.com> Hi John, could you squash this in? -- diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 53b9691..79dec73 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -465,7 +465,7 @@ static int fv_vssd_to_domain(CMPIInstance *inst, int ret = 1; int retr; const char *val; - const char *domtype; + const char *domtype = NULL; const char *ostype = "hvm"; struct capabilities *capsinfo = NULL; @@ -481,7 +481,6 @@ static int fv_vssd_to_domain(CMPIInstance *inst, } } else if (STREQC(pfx, "Xen")) { domain->type = DOMAIN_XENFV; - domtype = NULL; } else { CU_DEBUG("Unknown fullvirt domain type: %s", pfx); ret = 0; @@ -738,8 +737,10 @@ static int vssd_to_domain(CMPIInstance *inst, if (fullvirt || STREQC(pfx, "KVM")) { conn = connect_by_classname(_BROKER, cn, &s); - if (conn == NULL || (s.rc != CMPI_RC_OK)) { - CU_DEBUG("libvirt connection failed"); + if (conn == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Error connecting to libvirt"); ret = 0; goto out; } Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Fri Aug 30 11:54:14 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 30 Aug 2013 13:54:14 +0200 Subject: [Libvirt-cim] [PATCHv2 0/5] Initial Enablement of S390 In-Reply-To: <521FB48C.3000003@redhat.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> <521FB48C.3000003@redhat.com> Message-ID: <522087E6.4020108@linux.vnet.ibm.com> On 08/29/2013 10:52 PM, John Ferlan wrote: > > Things look good - cimtest and coverity tests both were happy. > > Since I had already ACK'd patch 1 which is now patch 1 & 2, consider the > ACK still valid. Also the old patch 2 ACK is still valid even with the > self find of the missing qemu check. > > I posted nits/questions separately about patches 4 & 5. Since I believe > you still need me to push, feel free to post either just a set of diffs > for me to squash into or a v3. We will gladly accept your kind offer. Diffs are on the way. > > Is there a desire to get this into a RHEL release eventually or into the > "next" RHEL release? I'd rather let this "soak" a while and then work > on getting a complete libvirt-cim into a future 6.n release over what I > have to do now which is patch 0.6.1 with 0.6.3 based patches... No reason to hurry, I'd also rather see this done well than quick. And - not meant to scare you :) - we are not done yet. There's a number of patches that we're still working on and will send out for review soon. Not all are strictly s390 related, this first series isn't either, but are needed to sensibly manage guests on s390. In case you (and others) are interested, the next patches will deal with: - full-functional consoles (mandatory for s390) - device addresses - per device boot order - and some other minor libvirt feature exploitation support Stay tuned... -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Fri Aug 30 12:12:20 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 30 Aug 2013 14:12:20 +0200 Subject: [Libvirt-cim] [PATCH] build: Don't use /bin/sh unconditionally Message-ID: <1377864740-28778-1-git-send-email-mihajlov@linux.vnet.ibm.com> provider-register.sh implicitly assumes that the shell has bash-like capabilities. On systems like Ubuntu this is not the case leading to a make postinstall failure when used with Pegasus. Changing the script shebang to /bin/bash to make this explicit. Further replace occurrences of sh to $(SHELL) in the Makefile invocations of provider-register.sh. Signed-off-by: Viktor Mihajlovski --- May not be relevant as libvirt-cim/pegasus isn't part of Debian-ish distros as far as I am aware of. But it is a constant source of annoyance... Makefile.am | 18 +++++++++--------- provider-register.sh | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index 63ed3c7..9e8e96b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -201,26 +201,26 @@ uninstall-local: done preinstall: - sh -x base_schema/install_base_schema.sh `pwd`/base_schema + $(SHELL) -x base_schema/install_base_schema.sh `pwd`/base_schema # Un/Register the providers and class definitions from/to the current CIMOM. # @CIMSERVER@ is set by the configure script postinstall: - sh provider-register.sh -v -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(MOFS)) - sh provider-register.sh -v -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) - sh provider-register.sh -v -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) + $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(MOFS)) + $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) + $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) if [[ @CIMSERVER@ = pegasus ]]; then \ - sh provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ + $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ fi virsh -v | grep -q '^0.3' && cp examples/diskpool.conf $(DISK_POOL_CONFIG) || true mkdir -p $(INFO_STORE) preuninstall: - sh provider-register.sh -v -d -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(MOFS)) - sh provider-register.sh -v -d -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) - sh provider-register.sh -v -d -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) + $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(MOFS)) + $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) + $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) if [[ @CIMSERVER@ = pegasus ]]; then \ - sh provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ + $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ fi rpm: clean diff --git a/provider-register.sh b/provider-register.sh index b907df1..b730ef3 100755 --- a/provider-register.sh +++ b/provider-register.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # $Id$ # ================================================================== # Copyright IBM Corp. 2005 -- 1.7.9.5 From jferlan at redhat.com Fri Aug 30 12:38:42 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 30 Aug 2013 08:38:42 -0400 Subject: [Libvirt-cim] [PATCHv2 0/5] Initial Enablement of S390 In-Reply-To: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <52209252.30008@redhat.com> On 08/29/2013 11:18 AM, Viktor Mihajlovski wrote: > The current libvirt-cim implementation makes some assumptions > that are only true for x86 architectures. As we want to > enable libvirt-cim for s390 we need to makes sure that > valid libvirt guest definitions are being built for that > architecture while not breaking the existing implementation. > > Patch 1 fixes potential memory access problems. > > Patches 2 and 3 introduce two new properties arch and machine, > effectively a pass-through of the underlying libvirt > properties, for the necessary distinction between x86 and > other guests, and suppress the default framebuffer for > s390. > > Patches 4 and 5 make sure that a minimal SVPC guest definition > (VSSD and RASD) will result in a correct libvirt guest definition > for the current hypervisor. > > Boris Fiuczynski (2): > libxkutil: Provide easy access to the libvirt capabilities > VSSM: Set default values based on libvirt capabilities on > DefineSystem calls > > Viktor Mihajlovski (3): > libxkutil: Improve domain.os_info cleanup > VSSD: Add properties for arch and machine > S390: Avoid the generation of default input and graphics > > libxkutil/Makefile.am | 2 + > libxkutil/capability_parsing.c | 556 +++++++++++++++++++++++++++++ > libxkutil/capability_parsing.h | 97 +++++ > libxkutil/device_parsing.c | 114 +++--- > libxkutil/device_parsing.h | 4 +- > libxkutil/xml_parse_test.c | 201 ++++++++++- > libxkutil/xmlgen.c | 6 + > schema/VSSD.mof | 6 + > src/Virt_VSSD.c | 9 + > src/Virt_VirtualSystemManagementService.c | 165 +++++---- > 10 files changed, 1033 insertions(+), 127 deletions(-) > create mode 100644 libxkutil/capability_parsing.c > create mode 100644 libxkutil/capability_parsing.h > > > V2 Changes > # Split original patch 1 into 2 patches (fix, new feature), otherwise unchanged > # Patch 3 also considers QEMU domains now, was KVM only > # Patches 4 and 5 address memory leaks and overwrites > # cimtest run completes without regressions on x86 > > This series (with the squashed in changes) is now pushed upstream. Thanks, John From mihajlov at linux.vnet.ibm.com Fri Aug 30 12:53:25 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 30 Aug 2013 14:53:25 +0200 Subject: [Libvirt-cim] [PATCHv2 0/5] Initial Enablement of S390 In-Reply-To: <52209252.30008@redhat.com> References: <1377789533-8945-1-git-send-email-mihajlov@linux.vnet.ibm.com> <52209252.30008@redhat.com> Message-ID: <522095C5.1080804@linux.vnet.ibm.com> On 08/30/2013 02:38 PM, John Ferlan wrote: > > This series (with the squashed in changes) is now pushed upstream. Thanks! -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294