[libvirt] [test-API][PATCH v2] Add volume upload and download cases
The cases only cover dir volume testing. v1: * test download storage volumes using storage download API. * test upload storage volumes using storage upload API. For upload case, only raw volume format is supported, other format will fail. The offset and length value should be chosen from 0 and 1048576, because upload size is set as 1M. * both case use blocking stream. * sample conf is added. v2: * move digest function to utils * rename cases with prefix 'dir_' to emphasise that they are only for dir vol testing Signed-off-by: Wayne Sun g...@redhat.com --- cases/storage_dir_vol_upload_download.conf | 127 ++ repos/storage/dir_vol_download.py | 131 +++ repos/storage/dir_vol_upload.py| 158 utils/utils.py | 24 4 files changed, 440 insertions(+), 0 deletions(-) create mode 100644 cases/storage_dir_vol_upload_download.conf create mode 100644 repos/storage/dir_vol_download.py create mode 100644 repos/storage/dir_vol_upload.py diff --git a/cases/storage_dir_vol_upload_download.conf b/cases/storage_dir_vol_upload_download.conf new file mode 100644 index 000..fd22720 --- /dev/null +++ b/cases/storage_dir_vol_upload_download.conf @@ -0,0 +1,127 @@ +storage:create_dir_pool +poolname +$defaultpoolname + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +0 +length +0 +clean + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +1048576 +length +0 +clean + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +0 +length +1048576 +clean + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +1048576 +length +1048576 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +raw +offset +0 +length +0 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qcow2 +offset +1048576 +length +0 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qed +offset +0 +length +1048576 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +raw +offset +1048576 +length +1048576 +clean + +storage:destroy_pool +poolname +$defaultpoolname diff --git a/repos/storage/dir_vol_download.py b/repos/storage/dir_vol_download.py new file mode 100644 index 000..ddf293b --- /dev/null +++ b/repos/storage/dir_vol_download.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# dir storage volume download testing + +import os +import string +from xml.dom import minidom + +import libvirt +from libvirt import libvirtError + +from src import sharedmod +from utils import utils + +required_params = ('poolname', 'volname', 'volformat', 'capacity', 'offset', + 'length',) +optional_params = {'xml' : 'xmls/dir_volume.xml', + } + +def get_pool_path(poolobj): + get pool xml description + +poolxml = poolobj.XMLDesc(0) + +logger.debug(the xml description of pool is %s % poolxml) + +doc = minidom.parseString(poolxml) +path_element = doc.getElementsByTagName('path')[0] +textnode = path_element.childNodes[0] +path_value = textnode.data + +return path_value + +def write_file(path, capacity): +write test data to file + +logger.info(write %s data into file %s % (capacity, path)) +out = utils.get_capacity_suffix_size(capacity) +f = open(path, 'w') +datastr = ''.join(string.lowercase + string.uppercase + + string.digits + '.' + '\n') +repeat = out['capacity_byte'] / 64 +data = ''.join(repeat * datastr) +f.write(data) +f.close() + +def handler(stream, data, file_): +return file_.write(data) + +def dir_vol_download(params): +test volume download and check + +global logger +logger = params['logger'] +poolname = params['poolname'] +volname = params['volname'] +volformat = params['volformat'] +offset = int(params['offset']) +length = int(params['length']) +
[libvirt] [test-API][PATCH] Add dir volume wipe cases
* add dir volume wipe and wipe pattern cases * wipe case compare wiped volume with zero volume file with same capacity * wipe pattern cases support algorithms in: zero|nnsa|dod|bsi|gutmann|schneier|pfitzner7|pfitzner33|random, Besides zero, other algorithms are patterns supported by scrub, some algorithm might fail due to scrub version. * the check method in wipe pattern case for each algorithm is the same, only to make sure digest before and after wipe is different. Signed-off-by: Wayne Sun g...@redhat.com --- cases/storage_dir_vol_wipe.conf | 132 repos/storage/dir_vol_wipe.py | 136 + repos/storage/dir_vol_wipe_pattern.py | 123 + 3 files changed, 391 insertions(+), 0 deletions(-) create mode 100644 cases/storage_dir_vol_wipe.conf create mode 100644 repos/storage/dir_vol_wipe.py create mode 100644 repos/storage/dir_vol_wipe_pattern.py diff --git a/cases/storage_dir_vol_wipe.conf b/cases/storage_dir_vol_wipe.conf new file mode 100644 index 000..aa39415 --- /dev/null +++ b/cases/storage_dir_vol_wipe.conf @@ -0,0 +1,132 @@ +storage:create_dir_pool +poolname +$defaultpoolname + +storage:dir_vol_wipe +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +2M +volformat +raw +clean + +storage:dir_vol_wipe +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qcow2 +clean + +storage:dir_vol_wipe +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +30M +volformat +qed +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +2M +volformat +raw +algorithm +zero +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qcow2 +algorithm +nnsa +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +30M +volformat +qed +algorithm +pfitzner7 +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +random +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +dod +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +bsi +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +gutmann +clean + + +storage:destroy_pool +poolname +$defaultpoolname diff --git a/repos/storage/dir_vol_wipe.py b/repos/storage/dir_vol_wipe.py new file mode 100644 index 000..c020b43 --- /dev/null +++ b/repos/storage/dir_vol_wipe.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python +# volume wipe testing + +import os +import string +from xml.dom import minidom + +import libvirt +from libvirt import libvirtError + +from src import sharedmod +from utils import utils + +required_params = ('poolname', 'volname', 'volformat', 'capacity',) +optional_params = {'xml' : 'xmls/dir_volume.xml', + } + +def get_pool_path(poolobj): + get pool xml description + +poolxml = poolobj.XMLDesc(0) + +logger.debug(the xml description of pool is %s % poolxml) + +doc = minidom.parseString(poolxml) +path_element = doc.getElementsByTagName('path')[0] +textnode = path_element.childNodes[0] +path_value = textnode.data + +return path_value + +def write_file(path, capacity): +write test data to file + +logger.info(write %s data into file %s % (capacity, path)) +out = utils.get_capacity_suffix_size(capacity) +f = open(path, 'w') +datastr = ''.join(string.lowercase + string.uppercase + + string.digits + '.' + '\n') +repeat = out['capacity_byte'] / 64 +data = ''.join(repeat * datastr) +f.write(data) +f.close() + +def dir_vol_wipe(params): +test volume download and check + +global logger +logger = params['logger'] +poolname = params['poolname'] +volname = params['volname'] +volformat = params['volformat'] +capacity = params['capacity'] +xmlstr = params['xml'] + +logger.info(the poolname is %s, volname is %s, volformat is %s % +(poolname, volname, volformat)) + +conn =
Re: [libvirt] [PATCH qom-cpu 01/11] target-i386: Don't set any KVM flag by default if KVM is disabled
On Fri, Jan 04, 2013 at 08:01:02PM -0200, Eduardo Habkost wrote: This is a cleanup that tries to solve two small issues: - We don't need a separate kvm_pv_eoi_features variable just to keep a constant calculated at compile-time, and this style would require adding a separate variable (that's declared twice because of the CONFIG_KVM ifdef) for each feature that's going to be enabled/disable by machine-type compat code. - The pc-1.3 code is setting the kvm_pv_eoi flag on cpuid_kvm_features even when KVM is disabled at runtime. This small incosistency in the cpuid_kvm_features field isn't a problem today because cpuid_kvm_features is ignored by the TCG code, but it may cause unexpected problems later when refactoring the CPUID handling code. This patch eliminates the kvm_pv_eoi_features variable and simply uses CONFIG_KVM and kvm_enabled() inside the enable_kvm_pv_eoi() compat function, so it enables kvm_pv_eoi only if KVM is enabled. I believe this makes the behavior of enable_kvm_pv_eoi() clearer and easier to understand. Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- Cc: k...@vger.kernel.org Cc: Michael S. Tsirkin m...@redhat.com Cc: Gleb Natapov g...@redhat.com Cc: Marcelo Tosatti mtosa...@redhat.com Changes v2: - Coding style fix --- target-i386/cpu.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 82685dc..e6435da 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -145,15 +145,17 @@ static uint32_t kvm_default_features = (1 KVM_FEATURE_CLOCKSOURCE) | (1 KVM_FEATURE_ASYNC_PF) | (1 KVM_FEATURE_STEAL_TIME) | (1 KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); -static const uint32_t kvm_pv_eoi_features = (0x1 KVM_FEATURE_PV_EOI); #else static uint32_t kvm_default_features = 0; -static const uint32_t kvm_pv_eoi_features = 0; #endif void enable_kvm_pv_eoi(void) { -kvm_default_features |= kvm_pv_eoi_features; +#ifdef CONFIG_KVM You do not need ifdef here. +if (kvm_enabled()) { +kvm_default_features |= (1UL KVM_FEATURE_PV_EOI); +} +#endif } void host_cpuid(uint32_t function, uint32_t count, -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH qom-cpu 02/11] target-i386: Disable kvm_mmu_op by default on pc-1.4
On Fri, Jan 04, 2013 at 08:01:03PM -0200, Eduardo Habkost wrote: The kvm_mmu_op feature was removed from the kernel since v3.3 (released in March 2012), it was marked for removal since January 2011 and it's slower than shadow or hardware assisted paging (see kernel commit fb92045843). It doesn't make sense to keep it enabled by default. Actually it was effectively removed Oct 1 2009 by a68a6a7282373. After 3 and a half years of not having it I think we can safely drop it without trying to preserve it in older machine types. Also, keeping it enabled by default would cause unnecessary hassle when libvirt start using the enforce option. Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- Cc: k...@vger.kernel.org Cc: Michael S. Tsirkin m...@redhat.com Cc: Gleb Natapov g...@redhat.com Cc: Marcelo Tosatti mtosa...@redhat.com Cc: libvir-list@redhat.com Cc: Jiri Denemark jdene...@redhat.com I was planning to reverse the logic of the compat init functions and make pc_init_pci_1_3() enable kvm_mmu_op and then call pc_init_pci_1_4() instead. But that would require changing pc_init_pci_no_kvmclock() and pc_init_isa() as well. So to keep the changes simple, I am keeping the pattern used when pc_init_pci_1_3() was introduced, making pc_init_pci_1_4() disable kvm_mmu_op and then call pc_init_pci_1_3(). Changes v2: - Coding style fix - Removed redundant comments above machine init functions --- hw/pc_piix.c | 9 - target-i386/cpu.c | 9 + target-i386/cpu.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 99747a7..a32af6a 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -217,6 +217,7 @@ static void pc_init1(MemoryRegion *system_memory, } } +/* machine init function for pc-0.14 - pc-1.2 */ static void pc_init_pci(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args-ram_size; @@ -238,6 +239,12 @@ static void pc_init_pci_1_3(QEMUMachineInitArgs *args) pc_init_pci(args); } +static void pc_init_pci_1_4(QEMUMachineInitArgs *args) +{ +disable_kvm_mmu_op(); +pc_init_pci_1_3(args); +} + static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args-ram_size; @@ -285,7 +292,7 @@ static QEMUMachine pc_machine_v1_4 = { .name = pc-1.4, .alias = pc, .desc = Standard PC, -.init = pc_init_pci_1_3, +.init = pc_init_pci_1_4, .max_cpus = 255, .is_default = 1, }; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e6435da..c83a566 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -158,6 +158,15 @@ void enable_kvm_pv_eoi(void) #endif } +void disable_kvm_mmu_op(void) +{ +#ifdef CONFIG_KVM No need for ifdef here too. +if (kvm_enabled()) { +kvm_default_features = ~(1UL KVM_FEATURE_MMU_OP); clear_bit() +} +#endif +} + void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 1283537..27c8d0c 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -1219,5 +1219,6 @@ void do_smm_enter(CPUX86State *env1); void cpu_report_tpr_access(CPUX86State *env, TPRAccess access); void enable_kvm_pv_eoi(void); +void disable_kvm_mmu_op(void); #endif /* CPU_I386_H */ -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH qom-cpu 03/11] target-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features
On Fri, Jan 04, 2013 at 08:01:04PM -0200, Eduardo Habkost wrote: The existing -cpu host code simply set every bit inside svm_features (initializing it to -1), and that makes it impossible to make the enforce/check options work properly when the user asks for SVM features explicitly in the command-line. So, instead of initializing svm_features to -1, use GET_SUPPORTED_CPUID to fill only the bits that are supported by the host (just like we do for all other CPUID feature words inside kvm_cpu_fill_host()). This will keep the existing behavior (as filter_features_for_kvm() already uses GET_SUPPORTED_CPUID to filter svm_features), but will allow us to properly check for KVM features inside kvm_check_features_against_host() later. For example, we will be able to make this: $ qemu-system-x86_64 -cpu ...,+pfthreshold,enforce refuse to start if the SVM pfthreshold feature is not supported by the host (after we fix kvm_check_features_against_host() to check SVM flags as well). Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com --- Changes v2: - Coding style (indentation) fix Cc: Gleb Natapov g...@redhat.com Cc: Marcelo Tosatti mtosa...@redhat.com Cc: Joerg Roedel j...@8bytes.org Cc: k...@vger.kernel.org --- target-i386/cpu.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index c83a566..c49a97c 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -908,13 +908,10 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def) } } -/* - * Every SVM feature requires emulation support in KVM - so we can't just - * read the host features here. KVM might even support SVM features not - * available on the host hardware. Just set all bits and mask out the - * unsupported ones later. - */ -x86_cpu_def-svm_features = -1; +/* Other KVM-specific feature fields: */ +x86_cpu_def-svm_features = +kvm_arch_get_supported_cpuid(s, 0x800A, 0, R_EDX); + #endif /* CONFIG_KVM */ } -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH qom-cpu 04/11] target-i386: kvm: Enable all supported KVM features for -cpu host
On Fri, Jan 04, 2013 at 08:01:05PM -0200, Eduardo Habkost wrote: When using -cpu host, we don't need to use the kvm_default_features variable, as the user is explicitly asking QEMU to enable all feature supported by the host. This changes the kvm_cpu_fill_host() code to use GET_SUPPORTED_CPUID to initialize the kvm_features field, so we get all host KVM features enabled. This will also allow use to properly check/enforce KVM features inside kvm_check_features_against_host() later. For example, we will be able to make this: $ qemu-system-x86_64 -cpu ...,+kvm_pv_eoi,enforce refuse to start if kvm_pv_eoi is not supported by the host (after we fix kvm_check_features_against_host() to check KVM flags as well). Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com --- Changes v2: - Coding style (indentation) fix Cc: Gleb Natapov g...@redhat.com Cc: Michael S. Tsirkin m...@redhat.com Cc: Marcelo Tosatti mtosa...@redhat.com Cc: k...@vger.kernel.org --- target-i386/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index c49a97c..e916ae0 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -911,6 +911,8 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def) /* Other KVM-specific feature fields: */ x86_cpu_def-svm_features = kvm_arch_get_supported_cpuid(s, 0x800A, 0, R_EDX); +x86_cpu_def-kvm_features = +kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX); #endif /* CONFIG_KVM */ } -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH qom-cpu 05/11] target-i386: check/enforce: Fix CPUID leaf numbers on error messages
On Fri, Jan 04, 2013 at 08:01:06PM -0200, Eduardo Habkost wrote: The -cpu check/enforce warnings are printing incorrect information about the missing flags. There are no feature flags on CPUID leaves 0 and 0x8000, but there were references to 0 and 0x8000 in the table at kvm_check_features_against_host(). This changes the model_features_t struct to contain the register number as well, so the error messages print the correct CPUID leaf+register information, instead of wrong CPUID leaf numbers. This also changes the format of the error messages, so they follow the CPUID.leaf.register.name [bit offset] convention used on Intel documentation. Example output: $ qemu-system-x86_64 -machine pc-1.0,accel=kvm -cpu Opteron_G4,+ia64,enforce warning: host doesn't support requested feature: CPUID.01H:EDX.ia64 [bit 30] warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26] warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28] warning: host doesn't support requested feature: CPUID.8001H:ECX.abm [bit 5] warning: host doesn't support requested feature: CPUID.8001H:ECX.sse4a [bit 6] warning: host doesn't support requested feature: CPUID.8001H:ECX.misalignsse [bit 7] warning: host doesn't support requested feature: CPUID.8001H:ECX.3dnowprefetch [bit 8] warning: host doesn't support requested feature: CPUID.8001H:ECX.xop [bit 11] warning: host doesn't support requested feature: CPUID.8001H:ECX.fma4 [bit 16] Unable to find x86 CPU definition $ Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com But see the question below. --- Cc: Gleb Natapov g...@redhat.com Cc: Marcelo Tosatti mtosa...@redhat.com Cc: k...@vger.kernel.org Changes v2: - Coding style fixes - Add assert() for invalid register numbers on unavailable_host_feature() --- target-i386/cpu.c | 42 +- target-i386/cpu.h | 3 +++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e916ae0..c3e5db8 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -124,6 +124,25 @@ static const char *cpuid_7_0_ebx_feature_name[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; +const char *get_register_name_32(unsigned int reg) +{ +static const char *reg_names[CPU_NB_REGS32] = { +[R_EAX] = EAX, +[R_ECX] = ECX, +[R_EDX] = EDX, +[R_EBX] = EBX, +[R_ESP] = ESP, +[R_EBP] = EBP, +[R_ESI] = ESI, +[R_EDI] = EDI, +}; + +if (reg CPU_NB_REGS32) { +return NULL; +} +return reg_names[reg]; +} + /* collects per-function cpuid data */ typedef struct model_features_t { @@ -132,7 +151,8 @@ typedef struct model_features_t { uint32_t check_feat; const char **flag_names; uint32_t cpuid; -} model_features_t; +int reg; +} model_features_t; int check_cpuid = 0; int enforce_cpuid = 0; @@ -923,10 +943,13 @@ static int unavailable_host_feature(struct model_features_t *f, uint32_t mask) for (i = 0; i 32; ++i) if (1 i mask) { -fprintf(stderr, warning: host cpuid %04x_%04x lacks requested - flag '%s' [0x%08x]\n, -f-cpuid 16, f-cpuid 0x, -f-flag_names[i] ? f-flag_names[i] : [reserved], mask); +const char *reg = get_register_name_32(f-reg); +assert(reg); +fprintf(stderr, warning: host doesn't support requested feature: +CPUID.%02XH:%s%s%s [bit %d]\n, +f-cpuid, reg, +f-flag_names[i] ? . : , +f-flag_names[i] ? f-flag_names[i] : , i); break; } return 0; @@ -945,13 +968,14 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) int rv, i; struct model_features_t ft[] = { {guest_def-features, host_def.features, -~0, feature_name, 0x}, +~0, feature_name, 0x0001, R_EDX}, {guest_def-ext_features, host_def.ext_features, -~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x0001}, +~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x0001, R_ECX}, {guest_def-ext2_features, host_def.ext2_features, -~PPRO_FEATURES, ext2_feature_name, 0x8000}, +~PPRO_FEATURES, ext2_feature_name, 0x8001, R_EDX}, {guest_def-ext3_features, host_def.ext3_features, -~CPUID_EXT3_SVM, ext3_feature_name, 0x8001}}; +~CPUID_EXT3_SVM, ext3_feature_name, 0x8001, R_ECX} Why do we exclude PPRO_FEATURES/CPUID_EXT3_SVM from been checked? +}; assert(kvm_enabled()); diff --git a/target-i386/cpu.h b/target-i386/cpu.h
Re: [libvirt] [Qemu-devel] [PATCH qom-cpu 05/11] target-i386: check/enforce: Fix CPUID leaf numbers on error messages
On Sun, Jan 06, 2013 at 04:12:54PM +0200, Gleb Natapov wrote: On Fri, Jan 04, 2013 at 08:01:06PM -0200, Eduardo Habkost wrote: The -cpu check/enforce warnings are printing incorrect information about the missing flags. There are no feature flags on CPUID leaves 0 and 0x8000, but there were references to 0 and 0x8000 in the table at kvm_check_features_against_host(). This changes the model_features_t struct to contain the register number as well, so the error messages print the correct CPUID leaf+register information, instead of wrong CPUID leaf numbers. This also changes the format of the error messages, so they follow the CPUID.leaf.register.name [bit offset] convention used on Intel documentation. Example output: $ qemu-system-x86_64 -machine pc-1.0,accel=kvm -cpu Opteron_G4,+ia64,enforce warning: host doesn't support requested feature: CPUID.01H:EDX.ia64 [bit 30] warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26] warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28] warning: host doesn't support requested feature: CPUID.8001H:ECX.abm [bit 5] warning: host doesn't support requested feature: CPUID.8001H:ECX.sse4a [bit 6] warning: host doesn't support requested feature: CPUID.8001H:ECX.misalignsse [bit 7] warning: host doesn't support requested feature: CPUID.8001H:ECX.3dnowprefetch [bit 8] warning: host doesn't support requested feature: CPUID.8001H:ECX.xop [bit 11] warning: host doesn't support requested feature: CPUID.8001H:ECX.fma4 [bit 16] Unable to find x86 CPU definition $ Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com But see the question below. Never mind. I found the answer in the following patches :) --- Cc: Gleb Natapov g...@redhat.com Cc: Marcelo Tosatti mtosa...@redhat.com Cc: k...@vger.kernel.org Changes v2: - Coding style fixes - Add assert() for invalid register numbers on unavailable_host_feature() --- target-i386/cpu.c | 42 +- target-i386/cpu.h | 3 +++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e916ae0..c3e5db8 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -124,6 +124,25 @@ static const char *cpuid_7_0_ebx_feature_name[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; +const char *get_register_name_32(unsigned int reg) +{ +static const char *reg_names[CPU_NB_REGS32] = { +[R_EAX] = EAX, +[R_ECX] = ECX, +[R_EDX] = EDX, +[R_EBX] = EBX, +[R_ESP] = ESP, +[R_EBP] = EBP, +[R_ESI] = ESI, +[R_EDI] = EDI, +}; + +if (reg CPU_NB_REGS32) { +return NULL; +} +return reg_names[reg]; +} + /* collects per-function cpuid data */ typedef struct model_features_t { @@ -132,7 +151,8 @@ typedef struct model_features_t { uint32_t check_feat; const char **flag_names; uint32_t cpuid; -} model_features_t; +int reg; +} model_features_t; int check_cpuid = 0; int enforce_cpuid = 0; @@ -923,10 +943,13 @@ static int unavailable_host_feature(struct model_features_t *f, uint32_t mask) for (i = 0; i 32; ++i) if (1 i mask) { -fprintf(stderr, warning: host cpuid %04x_%04x lacks requested - flag '%s' [0x%08x]\n, -f-cpuid 16, f-cpuid 0x, -f-flag_names[i] ? f-flag_names[i] : [reserved], mask); +const char *reg = get_register_name_32(f-reg); +assert(reg); +fprintf(stderr, warning: host doesn't support requested feature: +CPUID.%02XH:%s%s%s [bit %d]\n, +f-cpuid, reg, +f-flag_names[i] ? . : , +f-flag_names[i] ? f-flag_names[i] : , i); break; } return 0; @@ -945,13 +968,14 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) int rv, i; struct model_features_t ft[] = { {guest_def-features, host_def.features, -~0, feature_name, 0x}, +~0, feature_name, 0x0001, R_EDX}, {guest_def-ext_features, host_def.ext_features, -~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x0001}, +~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x0001, R_ECX}, {guest_def-ext2_features, host_def.ext2_features, -~PPRO_FEATURES, ext2_feature_name, 0x8000}, +~PPRO_FEATURES, ext2_feature_name, 0x8001, R_EDX}, {guest_def-ext3_features, host_def.ext3_features, -~CPUID_EXT3_SVM,
Re: [libvirt] [PATCH qom-cpu 06/11] target-i386: check/enforce: Do not ignore hypervisor flag
On Fri, Jan 04, 2013 at 08:01:07PM -0200, Eduardo Habkost wrote: We don't need any hack to ignore CPUID_EXT_HYPERVISOR anymore, because kvm_arch_get_supported_cpuid() now set CPUID_EXT_HYPERVISOR properly. So, this shouldn't introduce any behavior change, but it makes the code simpler. Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com --- My goal is to eliminate the check_feat field completely, as kvm_arch_get_supported_cpuid() should now really return all the bits we can set on all CPUID leaves. --- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index c3e5db8..42c4c99 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -970,7 +970,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) {guest_def-features, host_def.features, ~0, feature_name, 0x0001, R_EDX}, {guest_def-ext_features, host_def.ext_features, -~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x0001, R_ECX}, +~0, ext_feature_name, 0x0001, R_ECX}, {guest_def-ext2_features, host_def.ext2_features, ~PPRO_FEATURES, ext2_feature_name, 0x8001, R_EDX}, {guest_def-ext3_features, host_def.ext3_features, -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] [PATCH qom-cpu 07/11] target-i386: check/enforce: Check all CPUID.80000001H.EDX bits
On Fri, Jan 04, 2013 at 08:01:08PM -0200, Eduardo Habkost wrote: I have no idea why PPRO_FEATURES was being ignored on the check of the CPUID.8001H.EDX bits. I believe it was a mistake, and it was supposed to be ~(PPRO_FEATURES CPUID_EXT2_AMD_ALIASES) or just ~CPUID_EXT2_AMD_ALIASES, because some time ago kvm_cpu_fill_host() used the CPUID instruction directly (instead of kvm_arch_get_supported_cpuid()). But now kvm_cpu_fill_host() use kvm_arch_get_supported_cpuid(), and kvm_arch_get_supported_cpuid() returns all supported bits for CPUID.8001H.EDX, even the AMD aliases (that are explicitly copied from CPUID.01H.EDX), so we can make the code check/enforce all the CPUID.8001H.EDX bits. Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com --- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 42c4c99..ce64b98 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -972,7 +972,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) {guest_def-ext_features, host_def.ext_features, ~0, ext_feature_name, 0x0001, R_ECX}, {guest_def-ext2_features, host_def.ext2_features, -~PPRO_FEATURES, ext2_feature_name, 0x8001, R_EDX}, +~0, ext2_feature_name, 0x8001, R_EDX}, {guest_def-ext3_features, host_def.ext3_features, ~CPUID_EXT3_SVM, ext3_feature_name, 0x8001, R_ECX} }; -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] [PATCH qom-cpu 08/11] target-i386: check/enforce: Check SVM flag support as well
On Fri, Jan 04, 2013 at 08:01:09PM -0200, Eduardo Habkost wrote: When nested SVM is supported, the kernel returns the SVM flag on GET_SUPPORTED_CPUID[1], so we can check the SVM flag safely on kvm_check_features_against_host(). I don't know why the original code ignored the SVM flag. Maybe it was because kvm_cpu_fill_host() used the CPUID instruction directly instead of GET_SUPPORTED_CPUID [1] Older kernels (before v2.6.37) returned the SVM flag even if nested SVM was _not_ supported. So the only cases where this patch should change behavior is when SVM is being requested by the user or the CPU model, but not supported by the host. And on these cases we really want QEMU to abort if the enforce option is set. Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com --- Cc: Joerg Roedel j...@8bytes.org Cc: k...@vger.kernel.org Cc: libvir-list@redhat.com Cc: Jiri Denemark jdene...@redhat.com I'm CCing libvirt people in case having SVM enabled by default may cause trouble when libvirt starts using the enforce flag. I don't know if libvirt expects most of the QEMU CPU models to have nested SVM enabled. Changes v2: - Coding style fix --- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index ce64b98..a9dd959 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -974,7 +974,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) {guest_def-ext2_features, host_def.ext2_features, ~0, ext2_feature_name, 0x8001, R_EDX}, {guest_def-ext3_features, host_def.ext3_features, -~CPUID_EXT3_SVM, ext3_feature_name, 0x8001, R_ECX} +~0, ext3_feature_name, 0x8001, R_ECX} }; assert(kvm_enabled()); -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] [PATCH qom-cpu 09/11] target-i386: check/enforce: Eliminate check_feat field
On Fri, Jan 04, 2013 at 08:01:10PM -0200, Eduardo Habkost wrote: Now that all entries have check_feat=~0 on kvm_check_features_against_host(), we can eliminate check_feat entirely and make the code check all bits. This patch shouldn't introduce any behavior change, as check_feat is set to ~0 on all entries. Signed-off-by: Eduardo Habkost ehabk...@redhat.com Reviewed-by: Gleb Natapov g...@redhat.com --- Changes v2: - Coding style fix --- target-i386/cpu.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index a9dd959..1c3c7e1 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -148,7 +148,6 @@ const char *get_register_name_32(unsigned int reg) typedef struct model_features_t { uint32_t *guest_feat; uint32_t *host_feat; -uint32_t check_feat; const char **flag_names; uint32_t cpuid; int reg; @@ -956,8 +955,7 @@ static int unavailable_host_feature(struct model_features_t *f, uint32_t mask) } /* best effort attempt to inform user requested cpu flags aren't making - * their way to the guest. Note: ft[].check_feat ideally should be - * specified via a guest_def field to suppress report of extraneous flags. + * their way to the guest. * * This function may be called only if KVM is enabled. */ @@ -968,13 +966,13 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) int rv, i; struct model_features_t ft[] = { {guest_def-features, host_def.features, -~0, feature_name, 0x0001, R_EDX}, +feature_name, 0x0001, R_EDX}, {guest_def-ext_features, host_def.ext_features, -~0, ext_feature_name, 0x0001, R_ECX}, +ext_feature_name, 0x0001, R_ECX}, {guest_def-ext2_features, host_def.ext2_features, -~0, ext2_feature_name, 0x8001, R_EDX}, +ext2_feature_name, 0x8001, R_EDX}, {guest_def-ext3_features, host_def.ext3_features, -~0, ext3_feature_name, 0x8001, R_ECX} +ext3_feature_name, 0x8001, R_ECX} }; assert(kvm_enabled()); @@ -982,7 +980,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) kvm_cpu_fill_host(host_def); for (rv = 0, i = 0; i ARRAY_SIZE(ft); ++i) for (mask = 1; mask; mask = 1) -if (ft[i].check_feat mask *ft[i].guest_feat mask +if (*ft[i].guest_feat mask !(*ft[i].host_feat mask)) { unavailable_host_feature(ft[i], mask); rv = 1; -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] [PATCH qom-cpu 10/11] target-i386: Call kvm_check_features_against_host() only if CONFIG_KVM is set
On Fri, Jan 04, 2013 at 08:01:11PM -0200, Eduardo Habkost wrote: This will be necessary once kvm_check_features_against_host() starts using KVM-specific definitions (so it won't compile anymore if CONFIG_KVM is not set). Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- target-i386/cpu.c | 4 1 file changed, 4 insertions(+) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 1c3c7e1..876b0f6 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -936,6 +936,7 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def) #endif /* CONFIG_KVM */ } +#ifdef CONFIG_KVM static int unavailable_host_feature(struct model_features_t *f, uint32_t mask) { int i; @@ -987,6 +988,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) } return rv; } +#endif static void x86_cpuid_version_get_family(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) @@ -1410,10 +1412,12 @@ static int cpu_x86_parse_featurestr(x86_def_t *x86_cpu_def, char *features) x86_cpu_def-kvm_features = ~minus_kvm_features; x86_cpu_def-svm_features = ~minus_svm_features; x86_cpu_def-cpuid_7_0_ebx_features = ~minus_7_0_ebx_features; +#ifdef CONFIG_KVM if (check_cpuid kvm_enabled()) { if (kvm_check_features_against_host(x86_cpu_def) enforce_cpuid) goto error; } +#endif Provide kvm_check_features_against_host() stub if !CONFIG_KVM and drop ifdef here. return 0; error: -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH qom-cpu 11/11] target-i386: check/enforce: Check all feature words
On Fri, Jan 04, 2013 at 08:01:12PM -0200, Eduardo Habkost wrote: This adds the following feature words to the list of flags to be checked by kvm_check_features_against_host(): - cpuid_7_0_ebx_features - ext4_features - kvm_features - svm_features This will ensure the enforce flag works as it should: it won't allow QEMU to be started unless every flag that was requested by the user or defined in the CPU model is supported by the host. This patch may cause existing configurations where enforce wasn't preventing QEMU from being started to abort QEMU. But that's exactly the point of this patch: if a flag was not supported by the host and QEMU wasn't aborting, it was a bug in the enforce code. Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- Cc: Gleb Natapov g...@redhat.com Cc: Marcelo Tosatti mtosa...@redhat.com Cc: k...@vger.kernel.org Cc: libvir-list@redhat.com Cc: Jiri Denemark jdene...@redhat.com CCing libvirt people, as this is directly related to the planned usage of the enforce flag by libvirt. The libvirt team probably has a problem in their hands: libvirt should use enforce to make sure all requested flags are making their way into the guest (so the resulting CPU is always the same, on any host), but users may have existing working configurations where a flag is not supported by the guest and the user really doesn't care about it. Those configurations will necessarily break when libvirt starts using enforce. One example where it may cause trouble for common setups: pc-1.3 wants the kvm_pv_eoi flag enabled by default (so enforce will make sure it is enabled), but the user may have an existing VM running on a host without pv_eoi support. That setup is unsafe today because live-migration between different host kernel versions may enable/disable pv_eoi silently (that's why we need the enforce flag to be used by libvirt), but the user probably would like to be able to live-migrate that VM anyway (and have libvirt to just do the right thing). One possible solution to libvirt is to use enforce only on newer machine-types, so existing machines with older machine-types will keep the unsafe host-dependent-ABI behavior, but at least would keep live-migration working in case the user is careful. I really don't know what the libvirt team prefers, but that's the situation today. The longer we take to make enforce strict as it should and make libvirt finally use it, more users will have VMs with migration-unsafe unpredictable guest ABIs. Changes v2: - Coding style fix --- target-i386/cpu.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 876b0f6..52727ad 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -955,8 +955,9 @@ static int unavailable_host_feature(struct model_features_t *f, uint32_t mask) return 0; } -/* best effort attempt to inform user requested cpu flags aren't making - * their way to the guest. +/* Check if all requested cpu flags are making their way to the guest + * + * Returns 0 if all flags are supported by the host, non-zero otherwise. * * This function may be called only if KVM is enabled. */ @@ -973,7 +974,15 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) {guest_def-ext2_features, host_def.ext2_features, ext2_feature_name, 0x8001, R_EDX}, {guest_def-ext3_features, host_def.ext3_features, -ext3_feature_name, 0x8001, R_ECX} +ext3_feature_name, 0x8001, R_ECX}, +{guest_def-ext4_features, host_def.ext4_features, +NULL, 0xC001, R_EDX}, Since there is not name array for ext4_features they cannot be added or removed on the command line hence no need to check them, no? +{guest_def-cpuid_7_0_ebx_features, host_def.cpuid_7_0_ebx_features, +cpuid_7_0_ebx_feature_name, 7, R_EBX}, +{guest_def-svm_features, host_def.svm_features, +svm_feature_name, 0x800A, R_EDX}, +{guest_def-kvm_features, host_def.kvm_features, +kvm_feature_name, KVM_CPUID_FEATURES, R_EAX}, }; assert(kvm_enabled()); -- 1.7.11.7 -- Gleb. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/4] build: properly substitute virtlockd.socket
On Fri, Jan 04, 2013 at 03:36:46PM -0700, Eric Blake wrote: virtlockd.service could be installed to a configurable root, but virtlockd.socket was hardcoded to installation into a distro. * src/Makefile.am (virtlockd.service, virtlockd.socket): Drop unused substitutions. * src/locking/virtlockd.socket.in (ListenStream): Don't hard-code /var. --- src/Makefile.am | 4 src/locking/virtlockd.socket.in | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 0cc02ed..ba685bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1707,9 +1707,7 @@ endif virtlockd.service: locking/virtlockd.service.in $(top_builddir)/config.status $(AM_V_GEN)sed \ - -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ -e 's|[@]sbindir[@]|$(sbindir)|g' \ - -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \ $ $@-t \ chmod a+x $@-t\ mv $@-t $@ @@ -1717,8 +1715,6 @@ virtlockd.service: locking/virtlockd.service.in $(top_builddir)/config.status virtlockd.socket: locking/virtlockd.socket.in $(top_builddir)/config.status $(AM_V_GEN)sed \ -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ - -e 's|[@]sbindir[@]|$(sbindir)|g' \ - -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \ $ $@-t \ chmod a+x $@-t\ mv $@-t $@ diff --git a/src/locking/virtlockd.socket.in b/src/locking/virtlockd.socket.in index 0589a29..a6eef4f 100644 --- a/src/locking/virtlockd.socket.in +++ b/src/locking/virtlockd.socket.in @@ -2,7 +2,7 @@ Description=Virtual machine lock manager socket [Socket] -ListenStream=/var/run/libvirt/virtlockd/virtlockd.sock +ListenStream=@localstatedir@/run/libvirt/virtlockd/virtlockd.sock [Install] WantedBy=multi-user.target ACK -- Guido -- 1.8.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] build: .service files don't need to be executable
On Fri, Jan 04, 2013 at 03:36:47PM -0700, Eric Blake wrote: See also commit 66ff2dd, where we avoided installing these files as executables. * daemon/Makefile.am (libvirtd.service): Drop chmod. * tools/Makefile.am (libvirt-guests.service): Likewise. * src/Makefile.am (virtlockd.service, virtlockd.socket): Likewise. --- daemon/Makefile.am | 1 - src/Makefile.am| 2 -- tools/Makefile.am | 1 - 3 files changed, 4 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 60112ff..7bcc7e2 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -354,7 +354,6 @@ libvirtd.service: libvirtd.service.in $(top_builddir)/config.status -e 's|[@]sbindir[@]|$(sbindir)|g' \ -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \ $ $@-t \ - chmod a+x $@-t\ mv $@-t $@ diff --git a/src/Makefile.am b/src/Makefile.am index ba685bb..08611fb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1709,14 +1709,12 @@ virtlockd.service: locking/virtlockd.service.in $(top_builddir)/config.status $(AM_V_GEN)sed \ -e 's|[@]sbindir[@]|$(sbindir)|g' \ $ $@-t \ - chmod a+x $@-t\ mv $@-t $@ virtlockd.socket: locking/virtlockd.socket.in $(top_builddir)/config.status $(AM_V_GEN)sed \ -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ $ $@-t \ - chmod a+x $@-t\ mv $@-t $@ diff --git a/tools/Makefile.am b/tools/Makefile.am index 58dbfe7..3775914 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -260,7 +260,6 @@ libvirt-guests.service: libvirt-guests.service.in $(top_builddir)/config.status -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \ -e 's|[@]libexecdir[@]|$(libexecdir)|g' \ $ $@-t \ - chmod a+x $@-t\ mv $@-t $@ Now I see what you meant on your reply to my change. ACK. -- Guido -- 1.8.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] build: use common .in replacement mechanism
On Fri, Jan 04, 2013 at 03:36:45PM -0700, Eric Blake wrote: We had several different styles of .in conversion in our Makefiles: ALLCAPS, @ALLCAPS@, @lower@, ::lower:: Canonicalize on one form, to make it easier to copy and paste between .in files. Also, we were using some non-portable sed constructs: \@ is an undefined escape sequence (it happens to be @ itself in GNU sed, but POSIX allows it to mean something else), as well as risky behavior (failure to consistently quote things means a space in $(sysconfdir) could throw things off; also, Autoconf recommends using | rather than , or ! in the s||| operator, because | has to be quoted in shell and is therefore less likely to appear in file names than , or !). Fix all of these uses to follow the same syntax. * daemon/libvirtd.8.in: Switch to @var@. * tools/virt-xml-validate.in: Likewise. * tools/virt-pki-validate.in: Likewise. * src/locking/virtlockd.init.in: Likewise. * daemon/Makefile.am: Prefer | over ! in sed. (libvirtd.8): Prefer consistent substitution. (libvirtd.init, libvirtd.service): Avoid non-portable sed. * tools/Makefile.am (libvirt-guests.sh, libvirt-guests.init) (libvirt-guests.service): Likewise. (virt-xml-validate, virt-pki-validate, virt-sanlock-cleanup): Prefer consistent capitalization. * src/Makefile.am (virtlockd.init, virtlockd.service) (virtlockd.socket): Prefer consistent substitution. --- daemon/Makefile.am| 40 +- src/Makefile.am | 38 src/locking/virtlockd.init.in | 14 ++-- tools/Makefile.am | 50 +-- tools/virt-pki-validate.in| 2 +- tools/virt-sanlock-cleanup.in | 6 +++--- tools/virt-xml-validate.in| 2 +- 7 files changed, 76 insertions(+), 76 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 18a4bca..60112ff 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -## Copyright (C) 2005-2012 Red Hat, Inc. +## Copyright (C) 2005-2013 Red Hat, Inc. ## See COPYING.LIB for the License of this software INCLUDES = \ @@ -84,8 +84,8 @@ CLEANFILES += test_libvirtd.aug libvirtd.8: $(srcdir)/libvirtd.8.in $(AM_V_GEN)sed \ - -e 's!SYSCONFDIR!$(sysconfdir)!g' \ - -e 's!LOCALSTATEDIR!$(localstatedir)!g' \ + -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \ + -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ $ $@-t \ mv $@-t $@ @@ -181,7 +181,7 @@ endif libvirtd.policy: libvirtd.policy.in $(top_builddir)/config.status $(AM_V_GEN) sed \ - -e 's![@]authaction[@]!$(policyauth)!g' \ + -e 's|[@]authaction[@]|$(policyauth)|g' \ $ $@-t \ mv $@-t $@ BUILT_SOURCES += libvirtd.policy @@ -222,25 +222,25 @@ BUILT_SOURCES += $(LOGROTATE_CONFS) libvirtd.logrotate: libvirtd.logrotate.in $(AM_V_GEN)sed \ - -e 's![@]localstatedir[@]!$(localstatedir)!g' \ + -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ $ $@-t \ mv $@-t $@ libvirtd.qemu.logrotate: libvirtd.qemu.logrotate.in $(AM_V_GEN)sed \ - -e 's![@]localstatedir[@]!$(localstatedir)!g' \ + -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ $ $@-t \ mv $@-t $@ libvirtd.lxc.logrotate: libvirtd.lxc.logrotate.in $(AM_V_GEN)sed \ - -e 's![@]localstatedir[@]!$(localstatedir)!g' \ + -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ $ $@-t \ mv $@-t $@ libvirtd.uml.logrotate: libvirtd.uml.logrotate.in $(AM_V_GEN)sed \ - -e 's![@]localstatedir[@]!$(localstatedir)!g' \ + -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ $ $@-t \ mv $@-t $@ @@ -340,21 +340,21 @@ uninstall-init-systemd: endif # LIBVIRT_INIT_SCRIPT_SYSTEMD libvirtd.init: libvirtd.init.in $(top_builddir)/config.status - $(AM_V_GEN)sed \ - -e s!\@localstatedir\@!$(localstatedir)!g \ - -e s!\@sbindir\@!$(sbindir)!g \ - -e s!\@sysconfdir\@!$(sysconfdir)!g \ - $ $@-t \ - chmod a+x $@-t\ + $(AM_V_GEN)sed \ + -e 's|[@]localstatedir[@]|$(localstatedir)|g' \ + -e 's|[@]sbindir[@]|$(sbindir)|g' \ + -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \ + $ $@-t
Re: [libvirt] [PATCH 0/2] Add virsh commands to modify cpu node and model node of a domain XML
ping. I'd like to get any comment or advice. Thank you for considering my request. Ken Ichikawa (2012/12/25 17:40), Ken ICHIKAWA wrote: From: Ken ICHIKAWA ichikawa@jp.fujitsu.com This patchset adds two virsh commands, confcpu and confcpu-model. confcpu allows to modify 'mode' attirbute and 'match' attribute of a cpu node of a domain XML. confcpu-model allows to modify cpu model, 'fallback' attribute and 'vendor_id' attribute of a model node of a domain XML. By using these commands, we can easily change cpu mode, model and etc. by hand or shellscript without editing XML. Ken ICHIKAWA (2): virsh: Add a new command confcpu virsh: Add a new command confcpu-model tools/virsh-domain.c | 411 +++ tools/virsh.pod | 51 +++ 2 files changed, 462 insertions(+) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [test-API][PATCH v2] Add volume upload and download cases
On 01/06/2013 05:37 PM, Wayne Sun wrote: The cases only cover dir volume testing. v1: * test download storage volumes using storage download API. * test upload storage volumes using storage upload API. For upload case, only raw volume format is supported, other format will fail. The offset and length value should be chosen from 0 and 1048576, because upload size is set as 1M. * both case use blocking stream. * sample conf is added. v2: * move digest function to utils * rename cases with prefix 'dir_' to emphasise that they are only for dir vol testing Signed-off-by: Wayne Sun g...@redhat.com --- cases/storage_dir_vol_upload_download.conf | 127 ++ repos/storage/dir_vol_download.py | 131 +++ repos/storage/dir_vol_upload.py| 158 utils/utils.py | 24 4 files changed, 440 insertions(+), 0 deletions(-) create mode 100644 cases/storage_dir_vol_upload_download.conf create mode 100644 repos/storage/dir_vol_download.py create mode 100644 repos/storage/dir_vol_upload.py diff --git a/cases/storage_dir_vol_upload_download.conf b/cases/storage_dir_vol_upload_download.conf new file mode 100644 index 000..fd22720 --- /dev/null +++ b/cases/storage_dir_vol_upload_download.conf @@ -0,0 +1,127 @@ +storage:create_dir_pool +poolname +$defaultpoolname + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +0 +length +0 +clean + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +1048576 +length +0 +clean + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +0 +length +1048576 +clean + +storage:dir_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +10M +volformat +raw +offset +1048576 +length +1048576 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +raw +offset +0 +length +0 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qcow2 +offset +1048576 +length +0 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qed +offset +0 +length +1048576 +clean + +storage:dir_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +raw +offset +1048576 +length +1048576 +clean + +storage:destroy_pool +poolname +$defaultpoolname diff --git a/repos/storage/dir_vol_download.py b/repos/storage/dir_vol_download.py new file mode 100644 index 000..ddf293b --- /dev/null +++ b/repos/storage/dir_vol_download.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# dir storage volume download testing + +import os +import string +from xml.dom import minidom + +import libvirt +from libvirt import libvirtError + +from src import sharedmod +from utils import utils + +required_params = ('poolname', 'volname', 'volformat', 'capacity', 'offset', + 'length',) +optional_params = {'xml' : 'xmls/dir_volume.xml', + } + +def get_pool_path(poolobj): + get pool xml description + +poolxml = poolobj.XMLDesc(0) + +logger.debug(the xml description of pool is %s % poolxml) + +doc = minidom.parseString(poolxml) +path_element = doc.getElementsByTagName('path')[0] +textnode = path_element.childNodes[0] +path_value = textnode.data + +return path_value + +def write_file(path, capacity): +write test data to file + +logger.info(write %s data into file %s % (capacity, path)) +out = utils.get_capacity_suffix_size(capacity) +f = open(path, 'w') +datastr = ''.join(string.lowercase + string.uppercase + + string.digits + '.' + '\n') +repeat = out['capacity_byte'] / 64 +data = ''.join(repeat * datastr) +f.write(data) +f.close() + +def handler(stream, data, file_): +return file_.write(data) + +def dir_vol_download(params): +test volume download and check + +global logger +logger = params['logger'] +poolname = params['poolname'] +volname = params['volname'] +volformat = params['volformat'] +offset =
[libvirt] [test-API][PATCH] Add logical volume download and upload cases
This is for logical volume download and upload testing. * using download and upload API under class virStream. they are functions act as same with download/upload APIs under class virStorageVol, just different entrance. * using logical volume specified xml to create volume. no need to provide volume format. * check method is the same with dir vol download/upload cases. Signed-off-by: Wayne Sun g...@redhat.com --- cases/storage_logical_vol_upload_download.conf | 179 repos/storage/logical_vol_download.py | 125 + repos/storage/logical_vol_upload.py| 152 3 files changed, 456 insertions(+), 0 deletions(-) create mode 100644 cases/storage_logical_vol_upload_download.conf create mode 100644 repos/storage/logical_vol_download.py create mode 100644 repos/storage/logical_vol_upload.py diff --git a/cases/storage_logical_vol_upload_download.conf b/cases/storage_logical_vol_upload_download.conf new file mode 100644 index 000..51b640e --- /dev/null +++ b/cases/storage_logical_vol_upload_download.conf @@ -0,0 +1,179 @@ +storage:define_logical_pool +poolname +$defaultpoolname +sourcename +$defaultpoolname +sourcepath +$defaultpartition + +storage:build_logical_pool +poolname +$defaultpoolname + +storage:activate_pool +poolname +$defaultpoolname + +storage:logical_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +0 +length +0 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:logical_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +0 +length +1048576 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:logical_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +1048576 +length +0 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:logical_vol_download +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +1048576 +length +1048576 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:logical_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +0 +length +0 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:logical_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +0 +length +1048576 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:logical_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +1048576 +length +0 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:logical_vol_upload +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50 +offset +1048576 +length +1048576 +clean + +storage:delete_logical_volume +poolname +$defaultpoolname +volname +$defaultvolumename + +storage:destroy_pool +poolname +$defaultpoolname + +storage:delete_logical_pool +poolname +$defaultpoolname + +storage:undefine_pool +poolname +$defaultpoolname diff --git a/repos/storage/logical_vol_download.py b/repos/storage/logical_vol_download.py new file mode 100644 index 000..9797f36 --- /dev/null +++ b/repos/storage/logical_vol_download.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# logical storage volume download testing + +import os +import string +from xml.dom import minidom + +import libvirt +from libvirt import libvirtError + +from src import sharedmod +from utils import utils + +required_params = ('poolname', 'volname', 'capacity', 'offset', 'length',) +optional_params = {'xml' : 'xmls/logical_volume.xml', + } + +def get_pool_path(poolobj): + get pool xml description + +poolxml = poolobj.XMLDesc(0) + +logger.debug(the xml description of pool is %s % poolxml) + +doc = minidom.parseString(poolxml) +path_element = doc.getElementsByTagName('path')[0] +textnode =
Re: [libvirt] [test-API][PATCH] Add dir volume wipe cases
On 01/06/2013 05:40 PM, Wayne Sun wrote: * add dir volume wipe and wipe pattern cases * wipe case compare wiped volume with zero volume file with same capacity * wipe pattern cases support algorithms in: zero|nnsa|dod|bsi|gutmann|schneier|pfitzner7|pfitzner33|random, Besides zero, other algorithms are patterns supported by scrub, some algorithm might fail due to scrub version. * the check method in wipe pattern case for each algorithm is the same, only to make sure digest before and after wipe is different. Signed-off-by: Wayne Sun g...@redhat.com --- cases/storage_dir_vol_wipe.conf | 132 repos/storage/dir_vol_wipe.py | 136 + repos/storage/dir_vol_wipe_pattern.py | 123 + 3 files changed, 391 insertions(+), 0 deletions(-) create mode 100644 cases/storage_dir_vol_wipe.conf create mode 100644 repos/storage/dir_vol_wipe.py create mode 100644 repos/storage/dir_vol_wipe_pattern.py diff --git a/cases/storage_dir_vol_wipe.conf b/cases/storage_dir_vol_wipe.conf new file mode 100644 index 000..aa39415 --- /dev/null +++ b/cases/storage_dir_vol_wipe.conf @@ -0,0 +1,132 @@ +storage:create_dir_pool +poolname +$defaultpoolname + +storage:dir_vol_wipe +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +2M +volformat +raw +clean + +storage:dir_vol_wipe +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qcow2 +clean + +storage:dir_vol_wipe +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +30M +volformat +qed +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +2M +volformat +raw +algorithm +zero +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +50M +volformat +qcow2 +algorithm +nnsa +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +30M +volformat +qed +algorithm +pfitzner7 +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +random +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +dod +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +bsi +clean + +storage:dir_vol_wipe_pattern +poolname +$defaultpoolname +volname +$defaultvolumename +capacity +1K +volformat +raw +algorithm +gutmann +clean + + +storage:destroy_pool +poolname +$defaultpoolname diff --git a/repos/storage/dir_vol_wipe.py b/repos/storage/dir_vol_wipe.py new file mode 100644 index 000..c020b43 --- /dev/null +++ b/repos/storage/dir_vol_wipe.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python +# volume wipe testing + +import os +import string +from xml.dom import minidom + +import libvirt +from libvirt import libvirtError + +from src import sharedmod +from utils import utils + +required_params = ('poolname', 'volname', 'volformat', 'capacity',) +optional_params = {'xml' : 'xmls/dir_volume.xml', + } + +def get_pool_path(poolobj): + get pool xml description + +poolxml = poolobj.XMLDesc(0) + +logger.debug(the xml description of pool is %s % poolxml) + +doc = minidom.parseString(poolxml) +path_element = doc.getElementsByTagName('path')[0] +textnode = path_element.childNodes[0] +path_value = textnode.data + +return path_value + +def write_file(path, capacity): +write test data to file + +logger.info(write %s data into file %s % (capacity, path)) +out = utils.get_capacity_suffix_size(capacity) +f = open(path, 'w') +datastr = ''.join(string.lowercase + string.uppercase + + string.digits + '.' + '\n') +repeat = out['capacity_byte'] / 64 +data = ''.join(repeat * datastr) +f.write(data) +f.close() + +def dir_vol_wipe(params): +test volume download and check + +global logger +logger = params['logger'] +poolname = params['poolname'] +volname = params['volname'] +volformat = params['volformat'] +capacity = params['capacity'] +xmlstr = params['xml'] + +logger.info(the poolname is %s, volname is %s, volformat is %s % +