[libvirt] [PATCH v3] add a boot option to do strict boot
Seabios already added a new device type to halt booting. Qemu can add HALT at the end of bootindex string, then seabios will halt booting after trying to boot from all selected devices. This patch added a new boot option to configure if boot from un-selected devices. This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices. v2: add HALT entry in get_boot_devices_list() v3: rebase to latest qemu upstream Signed-off-by: Amos Kong ak...@redhat.com --- As we discussed in the past, we need to introduce a general query-config command to tell libvirt the supported options. Anthony will do it? http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg00349.html --- qemu-options.hx |8 ++-- vl.c| 25 - 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 30fb85d..06dd565 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -161,14 +161,14 @@ ETEXI DEF(boot, HAS_ARG, QEMU_OPTION_boot, -boot [order=drives][,once=drives][,menu=on|off]\n - [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n + [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n 'sp_time': the period that splash picture last if menu=on, unit is ms\n 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n, QEMU_ARCH_ALL) STEXI -@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}] +@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off] @findex -boot Specify boot order @var{drives} as a string of drive letters. Valid drive letters depend on the target achitecture. The x86 PC uses: a, b @@ -192,6 +192,10 @@ when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not reboot, qemu passes '-1' to bios by default. Currently Seabios for X86 system support it. +Do strict boot via @option{strict=on} as far as firmware/BIOS +supports it. This only effects when boot priority is changed by +bootindex options. The default is non-strict boot. + @example # try to boot from network first, then from hard disk qemu-system-i386 -boot order=nc diff --git a/vl.c b/vl.c index ce51e65..aeed7f4 100644 --- a/vl.c +++ b/vl.c @@ -234,6 +234,7 @@ int ctrl_grab = 0; unsigned int nb_prom_envs = 0; const char *prom_envs[MAX_PROM_ENVS]; int boot_menu; +bool boot_strict; uint8_t *boot_splash_filedata; size_t boot_splash_filedata_size; uint8_t qemu_extra_params_fw[2]; @@ -458,6 +459,9 @@ static QemuOptsList qemu_boot_opts = { }, { .name = reboot-timeout, .type = QEMU_OPT_STRING, +}, { +.name = strict, +.type = QEMU_OPT_STRING, }, { /*End of list */ } }, @@ -1267,6 +1271,12 @@ char *get_boot_devices_list(size_t *size) *size = total; +if (boot_strict *size 0) { +list[total-1] = '\n'; +list = g_realloc(list, total + 4); +memcpy(list[total], HALT, 4); +*size = total + 4; +} return list; } @@ -3131,7 +3141,7 @@ int main(int argc, char **argv, char **envp) static const char * const params[] = { order, once, menu, splash, splash-time, -reboot-timeout, NULL +reboot-timeout, strict, NULL }; char buf[sizeof(boot_devices)]; char *standard_boot_devices; @@ -3174,6 +3184,19 @@ int main(int argc, char **argv, char **envp) exit(1); } } +if (get_param_value(buf, sizeof(buf), +strict, optarg)) { +if (!strcmp(buf, on)) { +boot_strict = true; +} else if (!strcmp(buf, off)) { +boot_strict = false; +} else { +fprintf(stderr, +qemu: invalid option value '%s'\n, +buf); +exit(1); +} +} if (!qemu_opts_parse(qemu_find_opts(boot-opts), optarg, 0)) {
Re: [libvirt] [PATCH 0/5]Add startupPolicy attribute support for hard disks
On 03/18/2013 10:42 PM, Daniel P. Berrange wrote: On Mon, Mar 18, 2013 at 05:10:17PM +0800, Guannan Ren wrote: The set of patches is trying to add 'startupPolicy' attribute support to the source element of hard disks. Policy levels are using the mandatory, requisite, optional levels as originally documented. For the 'optional' policy, there is a little difference from CDROM and Floppy which only drop its source path, for disks, if missing, the checking function will drop their definitions, because qemu doesn't allow missing source path for hard disk. What is the motivation for this feature ? I personally find even the existing CDROM code for this to be of rather dubious value, so would like to see a clear use case for why we need to expand this hack. Daniel There is a real case from a libvirt customer request, which needs to make disk of block type use optional policy. The DR concept for our virtualization infrastructure is based upon host-based mirroring of independent SAN LUNs. Because RH does not support CLVM spanning multiple data centers we have to pass the LUNs to the KVM and mirror inside of the KVM. If there is an outage taking down a storage box or an entire DC, we will be unable to migrate, relocate or start any KVM, despite the KVM being able to run just on one side of the mirror. Declare all devices as optional. If there aren't any mirror parts left, the KVM will fail, but that is an acceptable behaviour that will be recognized by our monitoring software. There is no need to have libvirt guard against failure of storage devices in such a setup. https://bugzilla.redhat.com/show_bug.cgi?id=910171 Guannan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: Support setting the 'removable' flag for USB disks
This adds an attribute named 'removable' to the 'target' element of disks, which controls the removable flag. For instance, on a Linux guest it controls the value of /sys/block/$dev/removable. This option is only valid for USB disks (i.e. bus='usb'), and its default value is 'off', which is the same behaviour as before. To achieve this, 'removable=on' is appended to the '-device usb-storage' parameter sent to qemu when adding a USB disk via '-disk'. For versions of qemu only supporting '-usbdevice disk:' for adding USB disks this feature always remains 'off' since there's no support for passing such an option. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=922495 --- docs/formatdomain.html.in |8 +++-- docs/schemas/domaincommon.rng |8 + src/conf/domain_conf.c | 35 ++-- src/conf/domain_conf.h |9 + src/libvirt_private.syms |1 + src/qemu/qemu_command.c|6 .../qemuxml2argv-disk-usb-device-removable.args|8 + .../qemuxml2argv-disk-usb-device-removable.xml | 27 +++ tests/qemuxml2argvtest.c |2 ++ 9 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8a3c3b7..384da4f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1498,9 +1498,13 @@ removable disks (i.e. CDROM or Floppy disk), the value can be either open or closed, defaults to closed. NB, the value of codetray/code could be updated while the domain is running. -span class=sinceSince 0.0.3; codebus/code attribute since 0.4.3; +The optional attribute coderemovable/code sets the +removable flag for USB disks, and its value can be either on +or off, defaulting to off. span class=sinceSince +0.0.3; codebus/code attribute since 0.4.3; codetray/code attribute since 0.9.11; usb attribute value since -after 0.4.4; sata attribute value since 0.9.7/span +after 0.4.4; sata attribute value since 0.9.7; removable attribute +value since X.Y.Z/span /dd dtcodeiotune/code/dt ddThe optional codeiotune/code element provides the diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 9792065..eab6aa3 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1164,6 +1164,14 @@ /choice /attribute /optional + optional +attribute name=removable + choice +valueon/value +valueoff/value + /choice +/attribute + /optional /element /define define name=geometry diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3278e9c..551bac3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -709,6 +709,10 @@ VIR_ENUM_IMPL(virDomainDiskTray, VIR_DOMAIN_DISK_TRAY_LAST, closed, open); +VIR_ENUM_IMPL(virDomainDiskRemovable, VIR_DOMAIN_DISK_REMOVABLE_LAST, + on, + off); + VIR_ENUM_IMPL(virDomainNumatuneMemPlacementMode, VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_LAST, default, @@ -3996,6 +4000,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, char *authUUID = NULL; char *usageType = NULL; char *tray = NULL; +char *removable = NULL; char *logical_block_size = NULL; char *physical_block_size = NULL; char *wwn = NULL; @@ -4149,6 +4154,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, target = virXMLPropString(cur, dev); bus = virXMLPropString(cur, bus); tray = virXMLPropString(cur, tray); +removable = virXMLPropString(cur, removable); /* HACK: Work around for compat with Xen * driver in previous libvirt releases */ @@ -4556,6 +4562,24 @@ virDomainDiskDefParseXML(virCapsPtr caps, def-tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED; } +if (removable) { +if ((def-removable = virDomainDiskRemovableTypeFromString(removable)) 0) { +virReportError(VIR_ERR_XML_ERROR, + _(unknown disk removable status '%s'), removable); +goto error; +} + +if (def-bus != VIR_DOMAIN_DISK_BUS_USB) { +virReportError(VIR_ERR_XML_ERROR, %s, + _(removable is only valid for usb disks)); +goto error; +} +} else { +if (def-bus == VIR_DOMAIN_DISK_BUS_USB) { +def-removable = VIR_DOMAIN_DISK_REMOVABLE_OFF; +} +
[libvirt] qmp monitor is broken
Hi, $subject says it. Bisecting points to: commit 23673ca740e0eda66901ca801a5a901df378b063 Author: Anthony Liguori aligu...@us.ibm.com Date: Tue Mar 5 23:21:23 2013 +0530 qemu-char: add watch support This allows a front-end to request for a callback when the backend is writable again. Signed-off-by: Anthony Liguori aligu...@us.ibm.com Signed-off-by: Amit Shah amit.s...@redhat.com Symtoms: virsh start hangs (not always, but most of the time). When killing qemu it prints an error message: error: Failed to start domain fedora-org-virtio error: internal error cannot parse json {return: [{name: chardev-remove}, {name: chardev-add}, {name: query-target}, {name: query-cpu-definitions}, {name: query-machines}, {name: device-list-properties}, {name: qom-list-types}, {name: change-vnc-password}, {name: nbd-server-stop}, {name: nbd-server-add}, {name: nbd-server-start}, {name: qom-get}, {name: qom-set}, {name: qom-list}, {name: query-block-jobs}, {name: query-balloon}, {name: query-migrate-capabilities}, {name: migrate-set-capabilities}, {name: query-migrate}, {name: query-uuid}, {name: query-name}, {name: query-spice}, {name: query-vnc}, {name: query-mice}, {name: query-status}, {name: query-kvm}, {name: query-pci}, {name: query-cpus}, {name: query-blockstats}, {name: query-block}, {name: query-chardev}, {name: query-events}, {name: query-commands}, {name: query-version}, {name: human-monitor-command}, {name: qmp_capabilities So it looks like a bulky qmp reply is written incomplete (or corrupted) and libvirt waits forever for the missing bits ... cheers, Gerd -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-designer 1/2] Fix libvirt caps - libosinfo platform short id mapping
The code was building an id starting with kvm- while libosinfo qemu description uses qemu-kvm-. Also, starting from qemu 1.2.0, there is no separate qemu-kvm tarball. guess_platform_from_connect is starting to be a bit magic, it may be better to add a machine attribute to libosinfo platform description and to use this to improve the matching between libosinfo data and libvirt caps. --- examples/virtxml.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/virtxml.c b/examples/virtxml.c index 09f49cf..a68843d 100644 --- a/examples/virtxml.c +++ b/examples/virtxml.c @@ -442,13 +442,13 @@ guess_platform_from_connect(GVirConnection *conn) } /* do some mappings: - * QEMU - kvm + * QEMU - qemu-kvm * Xen - xen */ type = g_ascii_strdown(hv_type, -1); -if (g_str_equal(type, qemu)) { +if (g_str_equal(type, qemu) ver = 1002000) { g_free(type); -type = g_strdup(kvm); +type = g_strdup(qemu-kvm); } major = ver / 100; -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-designer 2/2] Add gvir_designer_get_osinfo_db
virtxml was doing its own loading of the libosinfo database, and gvir_designer_init() was loading it a second time. By adding a gvir_designer_get_osinfo_db() method, virtxml can use the same libosinfo database as the rest of libvirt-designer. --- examples/virtxml.c | 51 libvirt-designer/libvirt-designer-domain.c | 9 - libvirt-designer/libvirt-designer-internal.h | 3 -- libvirt-designer/libvirt-designer-main.c | 39 - libvirt-designer/libvirt-designer-main.h | 3 ++ libvirt-designer/libvirt-designer.sym| 1 + 6 files changed, 64 insertions(+), 42 deletions(-) diff --git a/examples/virtxml.c b/examples/virtxml.c index a68843d..8137c5a 100644 --- a/examples/virtxml.c +++ b/examples/virtxml.c @@ -35,7 +35,6 @@ GList *disk_str_list = NULL; GList *iface_str_list = NULL; -OsinfoDb *db = NULL; #define print_error(...) \ print_error_impl(__FUNCTION__, __LINE__, __VA_ARGS__) @@ -59,28 +58,6 @@ print_error_impl(const char *funcname, fprintf(stderr,\n); } -static gboolean -load_osinfo(void) -{ -GError *err = NULL; -gboolean ret = FALSE; -OsinfoLoader *loader = NULL; - -loader = osinfo_loader_new(); -osinfo_loader_process_default_path(loader, err); -if (err) { -print_error(Unable to load default libosinfo DB: %s, err-message); -g_clear_error(err); -} - -db = osinfo_loader_get_db(loader); -g_object_ref(db); -ret = TRUE; - -g_object_unref(loader); -return ret; -} - static gint entity_compare(gconstpointer a, gconstpointer b) { @@ -97,12 +74,14 @@ print_oses(const gchar *option_name, gpointer data, GError **error) { +OsinfoDb *db; OsinfoOsList *list = NULL; GList *oses = NULL; GList *os_iter; int ret = EXIT_FAILURE; -if (!db !load_osinfo()) +db = gvir_designer_get_osinfo_db(); +if (!db) goto cleanup; printf( Operating System ID\n @@ -137,12 +116,14 @@ print_platforms(const gchar *option_name, gpointer data, GError **error) { +OsinfoDb *db; OsinfoPlatformList *list = NULL; GList *platforms = NULL; GList *platform_iter; int ret = EXIT_FAILURE; -if (!db !load_osinfo()) +db = gvir_designer_get_osinfo_db(); +if (!db) goto cleanup; printf( Platform ID\n @@ -313,9 +294,11 @@ find_entity_by_short_id(OsinfoList *ent_list, static OsinfoOs * find_os(const gchar *os_str) { +OsinfoDb *db; OsinfoOs *ret = NULL; -if (!db !load_osinfo()) +db = gvir_designer_get_osinfo_db(); +if (!db) return NULL; ret = osinfo_db_get_os(db, os_str); @@ -326,11 +309,13 @@ find_os(const gchar *os_str) static OsinfoOs * find_os_by_short_id(const char *short_id) { +OsinfoDb *db; OsinfoOs *ret = NULL; OsinfoOsList *oses = NULL; OsinfoEntity *found = NULL; -if (!db !load_osinfo()) +db = gvir_designer_get_osinfo_db(); +if (!db) return NULL; oses = osinfo_db_get_os_list(db); @@ -353,10 +338,12 @@ cleanup: static OsinfoOs * guess_os_from_disk(GList *disk_list) { +OsinfoDb *db; OsinfoOs *ret = NULL; GList *list_it = NULL; -if (!db !load_osinfo()) +db = gvir_designer_get_osinfo_db(); +if (!db) return NULL; for (list_it = disk_list; list_it; list_it = list_it-next) { @@ -387,9 +374,11 @@ guess_os_from_disk(GList *disk_list) static OsinfoPlatform * find_platform(const char *platform_str) { +OsinfoDb *db; OsinfoPlatform *ret = NULL; -if (!db !load_osinfo()) +db = gvir_designer_get_osinfo_db(); +if (!db) return NULL; ret = osinfo_db_get_platform(db, platform_str); @@ -400,11 +389,13 @@ find_platform(const char *platform_str) static OsinfoPlatform * find_platform_by_short_id(const char *short_id) { +OsinfoDb *db; OsinfoPlatform *ret = NULL; OsinfoPlatformList *platforms = NULL; OsinfoEntity *found = NULL; -if (!db !load_osinfo()) +db = gvir_designer_get_osinfo_db(); +if (!db) goto cleanup; platforms = osinfo_db_get_platform_list(db); diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c index 3e31bd1..862daba 100644 --- a/libvirt-designer/libvirt-designer-domain.c +++ b/libvirt-designer/libvirt-designer-domain.c @@ -721,7 +721,14 @@ gvir_designer_domain_get_preferred_device(GVirDesignerDomain *design, OsinfoDeviceLink *dev_link = NULL; if (!deployment) { -priv-deployment = deployment = osinfo_db_find_deployment(osinfo_db, +OsinfoDb *db; +db = gvir_designer_get_osinfo_db(); +if (!db) { +g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0, +Unable to find any deployment in libosinfo database); +goto cleanup; +} +priv-deployment
Re: [libvirt] [PATCH v3 RESEND 3/4] NUMA: cleanup for numa related codes
On Tue, Mar 19, 2013 at 09:59:37AM +0800, Gao feng wrote: Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/conf/domain_conf.c | 17 ++- src/conf/domain_conf.h | 17 +-- src/libvirt_private.syms | 5 +- src/lxc/lxc_controller.c | 114 +- src/qemu/qemu_cgroup.c | 4 +- src/qemu/qemu_process.c | 121 + src/util/virnuma.c | 126 +++ src/util/virnuma.h | 30 +++ 8 files changed, 168 insertions(+), 266 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 96f11ba..98c4745 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -47,6 +47,7 @@ # include device_conf.h # include virbitmap.h # include virstoragefile.h +# include virnuma.h /* forward declarations of all device types, required by * virDomainDeviceDef @@ -1700,18 +1701,6 @@ virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def, int nvcpupin, int vcpu); -typedef struct _virDomainNumatuneDef virDomainNumatuneDef; -typedef virDomainNumatuneDef *virDomainNumatuneDefPtr; -struct _virDomainNumatuneDef { -struct { -virBitmapPtr nodemask; -int mode; -int placement_mode; /* enum virDomainNumatuneMemPlacementMode */ -} memory; - -/* Future NUMA tuning related stuff should go here. */ -}; - typedef struct _virBlkioDeviceWeight virBlkioDeviceWeight; typedef virBlkioDeviceWeight *virBlkioDeviceWeightPtr; struct _virBlkioDeviceWeight { @@ -1801,7 +1790,7 @@ struct _virDomainDef { virDomainVcpuPinDefPtr emulatorpin; } cputune; -virDomainNumatuneDef numatune; +virNumatuneDef numatune; /* These 3 are based on virDomainLifeCycleAction enum flags */ int onReboot; @@ -2396,8 +2385,6 @@ VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression) VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode) VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste) VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode) -VIR_ENUM_DECL(virDomainNumatuneMemMode) -VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode) VIR_ENUM_DECL(virDomainHyperv) VIR_ENUM_DECL(virDomainRNGModel) VIR_ENUM_DECL(virDomainRNGBackend) diff --git a/src/util/virnuma.h b/src/util/virnuma.h index d3d7d3e..ef201b9 100644 --- a/src/util/virnuma.h +++ b/src/util/virnuma.h @@ -22,7 +22,37 @@ #ifndef __VIR_NUMA_H__ # define __VIR_NUMA_H__ +# include internal.h +# include virbitmap.h +# include virutil.h + +enum virNumatuneMemPlacementMode { +VIR_NUMATUNE_MEM_PLACEMENT_MODE_DEFAULT = 0, +VIR_NUMATUNE_MEM_PLACEMENT_MODE_STATIC, +VIR_NUMATUNE_MEM_PLACEMENT_MODE_AUTO, + +VIR_NUMATUNE_MEM_PLACEMENT_MODE_LAST +}; This enum is previously defined in domain_conf.h, but you've not removed it from there, so now we have 2 enums for the same thing. Also you've ignore my request to use virNumaTune as the capatilization and VIR_NUMA_TUNE for enums + +VIR_ENUM_DECL(virNumatuneMemPlacementMode) + +VIR_ENUM_DECL(virDomainNumatuneMemMode) + +typedef struct _virNumatuneDef virNumatuneDef; +typedef virNumatuneDef *virNumatuneDefPtr; +struct _virNumatuneDef { +struct { +virBitmapPtr nodemask; +int mode; +int placement_mode; /* enum virNumatuneMemPlacementMode */ +} memory; + +/* Future NUMA tuning related stuff should go here. */ +}; Again virNumaTune should be the name prefix NACK, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-designer 2/2] Add gvir_designer_get_osinfo_db
On Tue, Mar 19, 2013 at 10:46:36AM +0100, Christophe Fergeau wrote: virtxml was doing its own loading of the libosinfo database, and gvir_designer_init() was loading it a second time. By adding a gvir_designer_get_osinfo_db() method, virtxml can use the same libosinfo database as the rest of libvirt-designer. --- examples/virtxml.c | 51 libvirt-designer/libvirt-designer-domain.c | 9 - libvirt-designer/libvirt-designer-internal.h | 3 -- libvirt-designer/libvirt-designer-main.c | 39 - libvirt-designer/libvirt-designer-main.h | 3 ++ libvirt-designer/libvirt-designer.sym| 1 + 6 files changed, 64 insertions(+), 42 deletions(-) I don't think we should be using a global variable for the osinfo database in libvirt-designer code at all. The libvirt designer APIs should allow the database to be passed by the caller where needed. This allows the app to have separate DBs for different scenarios if they so need, which could be useful in multi-threaded apps that want to avoid the need todo mutex locking on the DBs. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 0/6] Identity management APIs for RBAC
Ping, any more reviews welcome... Daniel On Wed, Mar 13, 2013 at 03:23:59PM +, Daniel P. Berrange wrote: An update of https://www.redhat.com/archives/libvir-list/2013-March/msg00186.html The first two patches are merged and fixes for the other patches applied. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/7] Support NBD volumes with LXC containers
Ping, any reviews welcome On Fri, Mar 15, 2013 at 04:32:37PM +, Daniel P. Berrange wrote: This series adds support for using non-raw disks with LXC containers by leverging NBD + qemu-nbd as an alternative to the loopback device. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/6] Add APIs for associating a virIdentityPtr with the current thread
On Wed, Mar 13, 2013 at 15:24:02 +, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com To allow any internal API to get the current identity, add APIs to associate a virIdentityPtr with the current thread, via a thread local Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/util/viridentity.c | 59 ++ src/util/viridentity.h | 3 +++ 2 files changed, 62 insertions(+) ACK Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/6] Add API to get the system identity
On Wed, Mar 13, 2013 at 15:24:03 +, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com If no user identity is available, some operations may wish to use the system identity. ie the identity of the current process itself. Add an API to get such an identity. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/util/viridentity.c | 71 ++ src/util/viridentity.h | 2 ++ 2 files changed, 73 insertions(+) diff --git a/src/util/viridentity.c b/src/util/viridentity.c index acb0cb9..1c43081 100644 --- a/src/util/viridentity.c +++ b/src/util/viridentity.c ... @@ -116,6 +122,71 @@ int virIdentitySetCurrent(virIdentityPtr ident) /** + * virIdentityGetSystem: + * + * Returns an identity that represents the system itself. + * This is the identity that the process is running as + * + * Returns a reference to the system identity, or NULL + */ +virIdentityPtr virIdentityGetSystem(void) +{ +char *username = NULL; +char *groupname = NULL; +char *seccontext = NULL; +virIdentityPtr ret = NULL; +gid_t gid = getgid(); +uid_t uid = getuid(); +#if HAVE_SELINUX +security_context_t con; +#endif + +if (!(username = virGetUserName(uid))) +goto cleanup; +if (!(groupname = virGetGroupName(gid))) +goto cleanup; Quite cosmetic, but is there any reason why we use uid/gid variables rather than calling getuid/getgid directly here? + +#if HAVE_SELINUX +if (getcon(con) 0) { +virReportSystemError(errno, %s, + _(Unable to lookup SELinux process context)); +goto cleanup; +} +seccontext = strdup(con); +freecon(con); +if (!seccontext) { +virReportOOMError(); +goto cleanup; +} +#endif + +if (!(ret = virIdentityNew())) +goto cleanup; + +if (username +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_UNIX_USER_NAME, username) 0) +goto error; +if (groupname +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_UNIX_GROUP_NAME, groupname) 0) +goto error; +if (seccontext +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_SECURITY_CONTEXT, seccontext) 0) +goto error; All three lines with virIdentitySetAttr() calls are too long. + +cleanup: +VIR_FREE(username); +VIR_FREE(groupname); +VIR_FREE(seccontext); +return ret; + +error: +virObjectUnref(ret); +ret = NULL; +goto cleanup; +} + + +/** * virIdentityNew: * * Creates a new empty identity object. After creating, one or ACK Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 5/6] Add ability to get a virIdentity from a virNetServerClientPtr
On Wed, Mar 13, 2013 at 15:24:04 +, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com Add APIs which allow creation of a virIdentity from the info associated with a virNetServerClientPtr instance. This is done based on the results of client authentication processes like TLS, x509, SASL, SO_PEERCRED ... diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 40c8173..850f388 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c ... @@ -642,6 +645,113 @@ int virNetServerClientGetUNIXIdentity(virNetServerClientPtr client, } +static virIdentityPtr +virNetServerClientCreateIdentity(virNetServerClientPtr client) +{ +char *processid = NULL; +char *username = NULL; +char *groupname = NULL; +#if WITH_SASL +char *saslname = NULL; +#endif +char *x509dname = NULL; +char *seccontext = NULL; +virIdentityPtr ret = NULL; + +if (client-sock virNetSocketIsLocal(client-sock)) { +gid_t gid; +uid_t uid; +pid_t pid; +if (virNetSocketGetUNIXIdentity(client-sock, uid, gid, pid) 0) +goto cleanup; + +if (!(username = virGetUserName(uid))) +goto cleanup; +if (!(groupname = virGetGroupName(gid))) +goto cleanup; +if (virAsprintf(processid, %d, (int)pid) 0) This should use %lld and (long long)pid to be consistent with the way we format PIDs in libvirt. Also you sould call virReportOOMError() here since virAsprintf() won't do it for you. +goto cleanup; +} + +#if WITH_SASL +if (client-sasl) { +const char *identity = virNetSASLSessionGetIdentity(client-sasl); +if (identity +!(saslname = strdup(identity))) { +virReportOOMError(); +goto cleanup; +} +} +#endif + +if (client-tls) { +const char *identity = virNetTLSSessionGetX509DName(client-tls); +if (identity +!(x509dname = strdup(identity))) { +virReportOOMError(); +goto cleanup; +} +} + +if (client-sock +virNetSocketGetSecurityContext(client-sock, seccontext) 0) +goto cleanup; + +if (!(ret = virIdentityNew())) +goto cleanup; + +if (username +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_UNIX_USER_NAME, username) 0) +goto error; +if (groupname +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_UNIX_GROUP_NAME, groupname) 0) +goto error; +if (processid +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_UNIX_PROCESS_ID, processid) 0) +goto error; +#if HAVE_SASL +if (saslname +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_SASL_USER_NAME, saslname) 0) +goto error; +#endif +if (x509dname +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_X509_DISTINGUISHED_NAME, x509dname) 0) +goto error; +if (seccontext +virIdentitySetAttr(ret, VIR_IDENTITY_ATTR_SECURITY_CONTEXT, seccontext) 0) +goto error; Long lines again. + +cleanup: +VIR_FREE(username); +VIR_FREE(groupname); +VIR_FREE(processid); +VIR_FREE(seccontext); +#if HAVE_SASL +VIR_FREE(saslname); +#endif +VIR_FREE(x509dname); +return ret; + +error: +virObjectUnref(ret); +ret = NULL; +goto cleanup; +} ... ACK Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/6] Define internal APIs for managing identities
On Wed, Mar 13, 2013 at 15:24:01 +, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com Introduce a local object virIdentity for managing security attributes used to form a client application's identity. Instances of this object are intended to be used as if they were immutable, once created populated with attributes ... diff --git a/src/util/virerror.c b/src/util/virerror.c index 40c3b25..8cb8548 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -118,6 +118,7 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST, SSH transport layer, /* 50 */ Lock Space, Init control, + Identity, ) @@ -1213,6 +1214,12 @@ virErrorMsg(virErrorNumber error, const char *info) else errmsg = _(resource busy %s); break; +case VIR_ERR_INVALID_IDENTITY: +if (info == NULL) +errmsg = _(invalid identity); +else +errmsg = _(invalid identity %s); +break; This doesn't seem to be used anywhere yet but would invalid identity: %s result in better error messages? } return errmsg; } diff --git a/src/util/viridentity.c b/src/util/viridentity.c new file mode 100644 index 000..7ebf851 --- /dev/null +++ b/src/util/viridentity.c ... +/** + * virIdentityIsEqual: + * @identA: the first identity + * @identB: the second identity + * + * Compares every attribute in @identA and @identB + * to determine if they refer to the same identity + * + * Returns 1 if they are equal, 0 if not equal or -1 on error + */ +int virIdentityIsEqual(virIdentityPtr identA, + virIdentityPtr identB) +{ +int ret = 0; +size_t i; +VIR_DEBUG(identA=%p identB=%p, identA, identB); + +for (i = 0 ; i VIR_IDENTITY_ATTR_LAST ; i++) { +if (STRNEQ_NULLABLE(identA-attrs[i], +identB-attrs[i])) +goto cleanup; +} + +ret = 1; +cleanup: +return ret; +} This API never fails, so why do we need to document unreachable -1 on error and use int rather than bool? Especially when you use this API as if it was just returning true/false. diff --git a/tests/viridentitytest.c b/tests/viridentitytest.c new file mode 100644 index 000..adb4f7d --- /dev/null +++ b/tests/viridentitytest.c ... +static int testIdentityAttrs(const void *data ATTRIBUTE_UNUSED) +{ +int ret = -1; +virIdentityPtr ident; +const char *val; + +if (!(ident = virIdentityNew())) +goto cleanup; + +if (virIdentitySetAttr(ident, + VIR_IDENTITY_ATTR_UNIX_USER_NAME, + fred) 0) +goto cleanup; + +if (virIdentityGetAttr(ident, + VIR_IDENTITY_ATTR_UNIX_USER_NAME, + val) 0) +goto cleanup; + +if (STRNEQ_NULLABLE(val, fred)) { +VIR_DEBUG(Expected 'fred' got '%s', NULLSTR(val)); +goto cleanup; +} + +if (virIdentityGetAttr(ident, + VIR_IDENTITY_ATTR_UNIX_GROUP_NAME, + val) 0) +goto cleanup; + +if (STRNEQ_NULLABLE(val, NULL)) { Hmm, could be easier to just check if val is NULL :-) +VIR_DEBUG(Unexpected groupname attribute); +goto cleanup; +} + +if (virIdentitySetAttr(ident, + VIR_IDENTITY_ATTR_UNIX_USER_NAME, + joe) != -1) { +VIR_DEBUG(Unexpectedly overwrote attribute); +goto cleanup; +} + +if (virIdentityGetAttr(ident, + VIR_IDENTITY_ATTR_UNIX_USER_NAME, + val) 0) +goto cleanup; + +if (STRNEQ_NULLABLE(val, fred)) { +VIR_DEBUG(Expected 'fred' got '%s', NULLSTR(val)); +goto cleanup; +} + +ret = 0; +cleanup: +virObjectUnref(ident); +return ret; +} + + +static int testIdentityEqual(const void *data ATTRIBUTE_UNUSED) +{ +int ret = -1; +virIdentityPtr identa = NULL; +virIdentityPtr identb = NULL; + +if (!(identa = virIdentityNew())) +goto cleanup; +if (!(identb = virIdentityNew())) +goto cleanup; + +if (!virIdentityIsEqual(identa, identb)) { +VIR_DEBUG(Empty identities were no equal); s/no/not/ +goto cleanup; +} ... ACK with the comments addressed. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 6/6] Set the current client identity during API call dispatch
On Wed, Mar 13, 2013 at 15:24:05 +, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com When dispatching an RPC API call, setup the current identity to hold the identity of the network client associated with the RPC message being dispatched. The setting is thread-local, so only affects the API call in this thread Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/rpc/virnetserverprogram.c | 12 1 file changed, 12 insertions(+) ACK Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/7] Setup LXC cgroups in two phases
On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com Currently the LXC controller creates the cgroup, configures the resources and adds the task all in one go. This is not sufficiently flexible for the forthcoming NBD integration. We need to make sure the NBD process gets into the right cgroup immediately, but we can not have limits (in particular the device ACL) applied at the point where we start qemu-nbd. So create a virLXCCgroupCreate method which creates the cgroup and adds the current ask to be called s/ask/task early, and leave virLXCCgroupSetup to only do resource config. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/lxc/lxc_cgroup.c | 39 +++ src/lxc/lxc_cgroup.h | 4 +++- src/lxc/lxc_controller.c | 12 +--- 3 files changed, 39 insertions(+), 16 deletions(-) ACK - seems reasonable to me. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Support setting the 'removable' flag for USB disks
On Tue, Mar 19, 2013 at 09:40:54AM +0100, anonym wrote: Can you use a real name instead of an anonymous psuedonym for patches. This adds an attribute named 'removable' to the 'target' element of disks, which controls the removable flag. For instance, on a Linux guest it controls the value of /sys/block/$dev/removable. This option is only valid for USB disks (i.e. bus='usb'), and its default value is 'off', which is the same behaviour as before. To achieve this, 'removable=on' is appended to the '-device usb-storage' parameter sent to qemu when adding a USB disk via '-disk'. For versions of qemu only supporting '-usbdevice disk:' for adding USB disks this feature always remains 'off' since there's no support for passing such an option. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=922495 --- docs/formatdomain.html.in |8 +++-- docs/schemas/domaincommon.rng |8 + src/conf/domain_conf.c | 35 ++-- src/conf/domain_conf.h |9 + src/libvirt_private.syms |1 + src/qemu/qemu_command.c|6 .../qemuxml2argv-disk-usb-device-removable.args|8 + .../qemuxml2argv-disk-usb-device-removable.xml | 27 +++ tests/qemuxml2argvtest.c |2 ++ 9 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.xml @@ -12915,10 +12940,14 @@ virDomainDiskDefFormat(virBufferPtr buf, if ((def-device == VIR_DOMAIN_DISK_DEVICE_FLOPPY || def-device == VIR_DOMAIN_DISK_DEVICE_CDROM) def-tray_status != VIR_DOMAIN_DISK_TRAY_CLOSED) -virBufferAsprintf(buf, tray='%s'/\n, +virBufferAsprintf(buf, tray='%s', virDomainDiskTrayTypeToString(def-tray_status)); -else -virBufferAddLit(buf, /\n); +if (def-bus == VIR_DOMAIN_DISK_BUS_USB +def-removable != VIR_DOMAIN_DISK_REMOVABLE_OFF) { This means that if the user explicitly added removeable='off' to their XML, we'll be dropping it. +virBufferAsprintf(buf, removable='%s', + virDomainDiskRemovableTypeToString(def-removable)); +} +virBufferAddLit(buf, /\n); /*disk I/O throttling*/ if (def-blkdeviotune.total_bytes_sec || diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 96f11ba..0f4f0d7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -518,6 +518,13 @@ enum virDomainDiskTray { VIR_DOMAIN_DISK_TRAY_LAST }; +enum virDomainDiskRemovable { If you add in VIR_DOMAIN_DISK_REMOVABLE_DEFAULT then you can distinguish explicit on/off settings from the default setting to address my earlier comment. +VIR_DOMAIN_DISK_REMOVABLE_ON, +VIR_DOMAIN_DISK_REMOVABLE_OFF, + +VIR_DOMAIN_DISK_REMOVABLE_LAST +}; + diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5cad990..0d1a9d6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -156,6 +156,7 @@ virDomainDiskIoTypeToString; virDomainDiskPathByName; virDomainDiskProtocolTransportTypeFromString; virDomainDiskProtocolTransportTypeToString; +virDomainDiskRemovableTypeToString; The VIR_ENUM macro generates 2 methods, so also add in virDomainDiskRemovableTypeFromString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4891b65..c04cecf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3219,6 +3219,11 @@ qemuBuildDriveDevStr(virDomainDefPtr def, if (disk-product) virBufferAsprintf(opt, ,product=%s, disk-product); +if (disk-bus == VIR_DOMAIN_DISK_BUS_USB +disk-removable != VIR_DOMAIN_DISK_REMOVABLE_OFF) { +virBufferAsprintf(opt, ,removable=%s, + virDomainDiskRemovableTypeToString(disk-removable)); +} We should should not on the QEMU default setting - so make sure you explicitly set both removeable=on or removeable=off. Also, not all versions of QEMU support this property, so you'll need to add a new capability flag in qemu_capabilities.h and then update qemu_capabilities.c to detect whether it exists or not. Then in this code, if you find a QEMU which does not support the flag, you should do a virRaiseError(VIR_ERR_CONFIG_UNSUPPORTED, ) to tell the user we can't do what they asked Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| --
Re: [libvirt] [PATCH 0/5]Add startupPolicy attribute support for hard disks
On Tue, Mar 19, 2013 at 03:56:40PM +0800, Guannan Ren wrote: On 03/18/2013 10:42 PM, Daniel P. Berrange wrote: On Mon, Mar 18, 2013 at 05:10:17PM +0800, Guannan Ren wrote: The set of patches is trying to add 'startupPolicy' attribute support to the source element of hard disks. Policy levels are using the mandatory, requisite, optional levels as originally documented. For the 'optional' policy, there is a little difference from CDROM and Floppy which only drop its source path, for disks, if missing, the checking function will drop their definitions, because qemu doesn't allow missing source path for hard disk. What is the motivation for this feature ? I personally find even the existing CDROM code for this to be of rather dubious value, so would like to see a clear use case for why we need to expand this hack. Daniel There is a real case from a libvirt customer request, which needs to make disk of block type use optional policy. The DR concept for our virtualization infrastructure is based upon host-based mirroring of independent SAN LUNs. Because RH does not support CLVM spanning multiple data centers we have to pass the LUNs to the KVM and mirror inside of the KVM. If there is an outage taking down a storage box or an entire DC, we will be unable to migrate, relocate or start any KVM, despite the KVM being able to run just on one side of the mirror. Declare all devices as optional. If there aren't any mirror parts left, the KVM will fail, but that is an acceptable behaviour that will be recognized by our monitoring software. There is no need to have libvirt guard against failure of storage devices in such a setup. Ok, so they are doing multi-pathing inside the guest, and so don't care if some of the LUNs on the host are not available when started. This makes more sense now as a feature. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 1/3] conf: support dtb tag in XML domain file
On Thu, Mar 14, 2013 at 12:49:42PM +0800, Olivia Yin wrote: --- docs/formatdomain.html.in |5 + docs/schemas/domaincommon.rng |6 ++ src/conf/domain_conf.c|4 src/conf/domain_conf.h|1 + 4 files changed, 16 insertions(+), 0 deletions(-) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] about Application_Development_Guide.pdf
HI,buddy. I'm sheldon. I'm trying to develop virtual machine lifecycle management software using libvirt. I found the development guide is very useful,it helps a lot. But this book I download from offical website is a draft,there are a lot of funcitons which are not claimed. I appreciate very much that you give me some document that developers are being in reference to . Best wishes! keep in touch. Yours sincely! .-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 2/3] qemu: add dtb option supprt
On Thu, Mar 14, 2013 at 12:49:43PM +0800, Olivia Yin wrote: The dtb option sets the filename for the device tree. If without this option support, -dtb file will be converted into qemu:commandline in domain XML file. For example, '-dtb /media/ram/test.dtb' will be converted into qemu:commandline qemu:arg value='-dtb'/ qemu:arg value='/media/ram/test.dtb'/ /qemu:commandline This is not very friendly. This patchset add special dtb tag like kernel and initrd which is easier for user to write domain XML file. os type arch='ppc' machine='ppce500v2'hvm/type kernel/media/ram/uImage/kernel initrd/media/ram/ramdisk/initrd dtb/media/ram/test.dtb/dtb cmdlineroot=/dev/ram rw console=ttyS0,115200/cmdline /os --- src/qemu/qemu_capabilities.c |8 - src/qemu/qemu_capabilities.h |1 + src/qemu/qemu_command.c |6 tests/qemuhelptest.c | 30 +-- tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args |1 + tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml | 28 ++ tests/qemuxml2argvtest.c |2 + tests/testutilsqemu.c| 33 ++ 8 files changed, 97 insertions(+), 12 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml ACK diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 79cfdb3..636608a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -210,7 +210,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, rng-random, /* 130 */ rng-egd, - virtio-ccw + virtio-ccw, + dtb, ); struct _virQEMUCaps { @@ -1173,8 +1174,10 @@ virQEMUCapsComputeCmdFlags(const char *help, if (version = 12000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_ROMBAR); -if (version = 11000) +if (version = 11000) { virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_HOST); +virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB); +} Doesn't '-dtb' show up in the -help output ? If it does, then it is preferrable to check for that, instead of using a version number based check @@ -2299,6 +2302,7 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps) virQEMUCapsSet(qemuCaps, QEMU_CAPS_NETDEV_BRIDGE); virQEMUCapsSet(qemuCaps, QEMU_CAPS_SECCOMP_SANDBOX); virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT); +virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB); This bit is fine for QMP. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 3/3] selinux: deal with dtb file
On Thu, Mar 14, 2013 at 12:49:44PM +0800, Olivia Yin wrote: --- src/security/security_dac.c |8 src/security/security_selinux.c |8 src/security/virt-aa-helper.c |4 3 files changed, 20 insertions(+), 0 deletions(-) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] about Application_Development_Guide.pdf
On Tue, Mar 19, 2013 at 02:17:43PM +0800, huyp1024 wrote: HI,buddy. I'm sheldon. I'm trying to develop virtual machine lifecycle management software using libvirt. I found the development guide is very useful,it helps a lot. But this book I download from offical website is a draft,there are a lot of funcitons which are not claimed. I appreciate very much that you give me some document that developers are being in reference to . We'd love this doc to be more complete, but we're lacking people with sufficient time / dedication to write for content for the docs. So I'm afraid it'll probably be an incomplete, draft for a while yet :-( If anyone out there is motivated to write more docs, we keep the source in GIT http://libvirt.org/git/?p=libvirt-appdev-guide.git;a=summary It is using DocBook XML format, to generate PDF + HTML output. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Support setting the 'removable' flag for USB disks
On 03/19/13 12:59, Daniel P. Berrange wrote: On Tue, Mar 19, 2013 at 09:40:54AM +0100, anonym wrote: Can you use a real name instead of an anonymous psuedonym for patches. This adds an attribute named 'removable' to the 'target' element of disks, which controls the removable flag. For instance, on a Linux guest it controls the value of /sys/block/$dev/removable. This option is only valid for USB disks (i.e. bus='usb'), and its default value is 'off', which is the same behaviour as before. To achieve this, 'removable=on' is appended to the '-device usb-storage' parameter sent to qemu when adding a USB disk via '-disk'. For versions of qemu only supporting '-usbdevice disk:' for adding USB disks this feature always remains 'off' since there's no support for passing such an option. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=922495 --- docs/formatdomain.html.in |8 +++-- docs/schemas/domaincommon.rng |8 + src/conf/domain_conf.c | 35 ++-- src/conf/domain_conf.h |9 + src/libvirt_private.syms |1 + src/qemu/qemu_command.c|6 .../qemuxml2argv-disk-usb-device-removable.args|8 + .../qemuxml2argv-disk-usb-device-removable.xml | 27 +++ tests/qemuxml2argvtest.c |2 ++ 9 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.xml ... /*disk I/O throttling*/ if (def-blkdeviotune.total_bytes_sec || diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 96f11ba..0f4f0d7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -518,6 +518,13 @@ enum virDomainDiskTray { VIR_DOMAIN_DISK_TRAY_LAST }; +enum virDomainDiskRemovable { If you add in VIR_DOMAIN_DISK_REMOVABLE_DEFAULT then you can distinguish explicit on/off settings from the default setting to address my earlier comment. +VIR_DOMAIN_DISK_REMOVABLE_ON, +VIR_DOMAIN_DISK_REMOVABLE_OFF, + +VIR_DOMAIN_DISK_REMOVABLE_LAST Or use VIR_DOMAIN_FEATURE_STATE_[DEFAULT|ON|OFF|LAST] that I introduced specifically to avoid adding enums like this for every feature. +}; + Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/5]Add startupPolicy attribute support for hard disks
On 03/19/2013 08:21 PM, Daniel P. Berrange wrote: On Tue, Mar 19, 2013 at 03:56:40PM +0800, Guannan Ren wrote: On 03/18/2013 10:42 PM, Daniel P. Berrange wrote: On Mon, Mar 18, 2013 at 05:10:17PM +0800, Guannan Ren wrote: The set of patches is trying to add 'startupPolicy' attribute support to the source element of hard disks. Policy levels are using the mandatory, requisite, optional levels as originally documented. For the 'optional' policy, there is a little difference from CDROM and Floppy which only drop its source path, for disks, if missing, the checking function will drop their definitions, because qemu doesn't allow missing source path for hard disk. What is the motivation for this feature ? I personally find even the existing CDROM code for this to be of rather dubious value, so would like to see a clear use case for why we need to expand this hack. Daniel There is a real case from a libvirt customer request, which needs to make disk of block type use optional policy. The DR concept for our virtualization infrastructure is based upon host-based mirroring of independent SAN LUNs. Because RH does not support CLVM spanning multiple data centers we have to pass the LUNs to the KVM and mirror inside of the KVM. If there is an outage taking down a storage box or an entire DC, we will be unable to migrate, relocate or start any KVM, despite the KVM being able to run just on one side of the mirror. Declare all devices as optional. If there aren't any mirror parts left, the KVM will fail, but that is an acceptable behaviour that will be recognized by our monitoring software. There is no need to have libvirt guard against failure of storage devices in such a setup. Ok, so they are doing multi-pathing inside the guest, and so don't care if some of the LUNs on the host are not available when started. This makes more sense now as a feature. Regards, Daniel Okay, thanks, I will rebase this patchset because [3/5] has been pushed by the same patch from Jiri. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/6] Add API to get the system identity
On Tue, Mar 19, 2013 at 12:21:31PM +0100, Jiri Denemark wrote: On Wed, Mar 13, 2013 at 15:24:03 +, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com If no user identity is available, some operations may wish to use the system identity. ie the identity of the current process itself. Add an API to get such an identity. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/util/viridentity.c | 71 ++ src/util/viridentity.h | 2 ++ 2 files changed, 73 insertions(+) diff --git a/src/util/viridentity.c b/src/util/viridentity.c index acb0cb9..1c43081 100644 --- a/src/util/viridentity.c +++ b/src/util/viridentity.c ... @@ -116,6 +122,71 @@ int virIdentitySetCurrent(virIdentityPtr ident) /** + * virIdentityGetSystem: + * + * Returns an identity that represents the system itself. + * This is the identity that the process is running as + * + * Returns a reference to the system identity, or NULL + */ +virIdentityPtr virIdentityGetSystem(void) +{ +char *username = NULL; +char *groupname = NULL; +char *seccontext = NULL; +virIdentityPtr ret = NULL; +gid_t gid = getgid(); +uid_t uid = getuid(); +#if HAVE_SELINUX +security_context_t con; +#endif + +if (!(username = virGetUserName(uid))) +goto cleanup; +if (!(groupname = virGetGroupName(gid))) +goto cleanup; Quite cosmetic, but is there any reason why we use uid/gid variables rather than calling getuid/getgid directly here? No particular reason, I'll change that. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/6] Define internal APIs for managing identities
On Tue, Mar 19, 2013 at 12:20:51PM +0100, Jiri Denemark wrote: On Wed, Mar 13, 2013 at 15:24:01 +, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com Introduce a local object virIdentity for managing security attributes used to form a client application's identity. Instances of this object are intended to be used as if they were immutable, once created populated with attributes ... diff --git a/src/util/virerror.c b/src/util/virerror.c index 40c3b25..8cb8548 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -118,6 +118,7 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST, SSH transport layer, /* 50 */ Lock Space, Init control, + Identity, ) @@ -1213,6 +1214,12 @@ virErrorMsg(virErrorNumber error, const char *info) else errmsg = _(resource busy %s); break; +case VIR_ERR_INVALID_IDENTITY: +if (info == NULL) +errmsg = _(invalid identity); +else +errmsg = _(invalid identity %s); +break; This doesn't seem to be used anywhere yet but would invalid identity: %s result in better error messages? Oh this is left over from earlier versions fo the patch. I'll kill it now. } return errmsg; } diff --git a/src/util/viridentity.c b/src/util/viridentity.c new file mode 100644 index 000..7ebf851 --- /dev/null +++ b/src/util/viridentity.c ... +/** + * virIdentityIsEqual: + * @identA: the first identity + * @identB: the second identity + * + * Compares every attribute in @identA and @identB + * to determine if they refer to the same identity + * + * Returns 1 if they are equal, 0 if not equal or -1 on error + */ +int virIdentityIsEqual(virIdentityPtr identA, + virIdentityPtr identB) +{ +int ret = 0; +size_t i; +VIR_DEBUG(identA=%p identB=%p, identA, identB); + +for (i = 0 ; i VIR_IDENTITY_ATTR_LAST ; i++) { +if (STRNEQ_NULLABLE(identA-attrs[i], +identB-attrs[i])) +goto cleanup; +} + +ret = 1; +cleanup: +return ret; +} This API never fails, so why do we need to document unreachable -1 on error and use int rather than bool? Especially when you use this API as if it was just returning true/false. Again, left over cruft from earlier versions. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/7] Add support for storage format in FS driver
On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com Extend the driver element in filesystem devices to allow a storage format to be set. The new attribute uses 'format' to reflect the storage format. This is different from the driver element in disk devices which use 'type' to reflect the storage format. THis s/THis/This is because the 'type' attribute on filesystem devices is already used for the driver backend, for which the disk devices use the 'name' attribte. Arh. s/attribte/attribute Your call on the Arh Anyway for disks we have driver name=qemu type=raw/ And for filesystems this change means we now have driver type=loop format=raw/ Signed-off-by: Daniel P. Berrange berra...@redhat.com --- docs/formatdomain.html.in | 24 ++ docs/schemas/domaincommon.rng | 73 ++- src/conf/domain_conf.c| 25 --- src/conf/domain_conf.h| 6 ++-- src/qemu/qemu_command.c | 3 +- 5 files changed, 102 insertions(+), 29 deletions(-) ACK Although the rng defs are still a bit of black magic to me. I suppose one could say the driver element options could be better described with respect to their possible/valid options in both the hard drives/floppy disks/cdroms and filesystems section of the documentation. With your new description you list since 1.0.4 for the driver element, but it seems using driver was available before that and the new 1.0.4 addition is the loop/format options. At least that's how I read it. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/7] Re-arrange code setting up ifs/disk loop devices for LXC
On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com The current code for setting up loop devices to LXC disks first does a switch() based on the disk format, then looks at the disk driver name. Reverse this so it first looks at the driver name, and then the disk format. This is more useful since the list of supported disk formats depends on what driver is used. The code for setting loop devices for LXC fs entries also needs to have the same logic added, now the XML schema supports this. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/lxc/lxc_controller.c | 76 +++- 1 file changed, 43 insertions(+), 33 deletions(-) ACK I take it the checking for FS_DRIVER_TYPE_LOOP in the first loop is just an optimization (or sanity check) over making more calls and determining the same thing. IOW previous the first loop didn't care about fsdriver type before making the SetupLoopDeviceFS call, but that could fail if it wasn't a loop device. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/7] Add a helper API for setting up a NBD device with qemu-nbd
On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com Add a virFileNBDDeviceAssociate method, which given a filename will setup a NBD device, using qemu-nbd as the server. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/libvirt_private.syms | 1 + src/util/virfile.c | 124 +++ src/util/virfile.h | 4 ++ 3 files changed, 129 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5cad990..0607bae 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1253,6 +1253,7 @@ virFileDirectFdFlag; virFileFclose; virFileFdopen; virFileLoopDeviceAssociate; +virFileNBDDeviceAssociate; virFileRewrite; virFileTouch; virFileUpdatePerm; diff --git a/src/util/virfile.c b/src/util/virfile.c index 4a9fa81..095559e 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -631,6 +631,119 @@ cleanup: return lofd; } + +# define SYSFS_BLOCK_DIR /sys/block + + +static int +virFileNBDDeviceIsBusy(const char *devname) +{ +char *path; +int ret = -1; + +if (virAsprintf(path, SYSFS_BLOCK_DIR /%s/pid, +devname) 0) { +virReportOOMError(); +return -1; +} + +if (access(path, F_OK) 0) { +if (errno == ENOENT) +ret = 0; +else +virReportSystemError(errno, + _(Cannot check NBD device %s pid), + devname); +goto cleanup; +} +ret = 1; + +cleanup: +VIR_FREE(path); +return ret; +} + + +static char * +virFileNBDDeviceFindUnused(void) +{ +DIR *dh; +char *ret = NULL; +struct dirent *de; + +if (!(dh = opendir(SYSFS_BLOCK_DIR))) { +virReportSystemError(errno, + _(Cannot read directory %s), + SYSFS_BLOCK_DIR); +return NULL; +} + +while ((de = readdir(dh)) != NULL) { +if (STRPREFIX(de-d_name, nbd)) { +int rv = virFileNBDDeviceIsBusy(de-d_name); +if (rv 0) +goto cleanup; +if (rv == 0) { +if (virAsprintf(ret, /dev/%s, de-d_name) 0) { +virReportOOMError(); +goto cleanup; +} +goto cleanup; +} +} +} + +virReportSystemError(EBUSY, %s, + _(No free NBD devices)); + +cleanup: +closedir(dh); +return ret; +} + + +int virFileNBDDeviceAssociate(const char *file, + char **dev, + bool readonly) +{ +char *nbddev; +char *qemunbd; +virCommandPtr cmd = NULL; +int ret = -1; + +if (!(nbddev = virFileNBDDeviceFindUnused())) +goto cleanup; + +if (!(qemunbd = virFindFileInPath(qemu-nbd))) { +virReportSystemError(ENOENT, %s, + _(Unable to find 'qemu-nbd' binary in $PATH)); +goto cleanup; +} + +cmd = virCommandNew(qemunbd); +if (readonly) +virCommandAddArg(cmd, -r); +virCommandAddArgList(cmd, + -n, /* Don't cache in qemu-nbd layer */ + -c, nbddev, + file, NULL); + +/* qemu-nbd will daemonize itself */ + +if (virCommandRun(cmd, NULL) 0) +goto cleanup; + +*dev = nbddev; +nbddev = NULL; +ret = 0; + +cleanup: +VIR_FREE(nbddev); +VIR_FREE(qemunbd); +virCommandFree(cmd); +return ret; +} + #else /* __linux__ */ int virFileLoopDeviceAssociate(const char *file, @@ -643,4 +756,15 @@ int virFileLoopDeviceAssociate(const char *file, return -1; } +int virFileNBDDeviceAssociate(const char *file, + char **dev ATTRIBUTE_UNUSED, + bool readonly ATTRIBUTE_UNUSED) +{ +virReportSystemError(ENOSYS, + _(Unable to associate file %s with NBD device), + file); +*dev = NULL; Since this is done - should this still be UNUSED in the header? +return -1; +} + #endif /* __linux__ */ diff --git a/src/util/virfile.h b/src/util/virfile.h index c885b73..6c9179b 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -108,4 +108,8 @@ int virFileUpdatePerm(const char *path, int virFileLoopDeviceAssociate(const char *file, char **dev); +int virFileNBDDeviceAssociate(const char *file, + char **dev, + bool readonly); + #endif /* __VIR_FILES_H */ ACK in any case. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 4/4] event: add hard disk dropping event reason enum
VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START --- include/libvirt/libvirt.h.in | 1 + src/qemu/qemu_domain.c | 18 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index f6a7aff..72df5a2 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -4603,6 +4603,7 @@ typedef void (*virConnectDomainEventBlockJobCallback)(virConnectPtr conn, */ typedef enum { VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START = 0, /* oldSrcPath is set */ +VIR_DOMAIN_EVENT_HARDDISK_DROP_MISSING_ON_START = 1, #ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_DISK_CHANGE_LAST diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4594b2c..7ce8b1d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1907,22 +1907,30 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, due to inaccessible source '%s', disk-dst, def-name, uuid, disk-src); -event = virDomainEventDiskChangeNewFromObj(vm, disk-src, NULL, disk-info.alias, - VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START); -if (event) -qemuDomainEventQueue(driver, event); - /* For CDROM and Floppy disk, only drop source path. * For Hard disk, drop its definition. */ if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM || disk-device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { + +event = virDomainEventDiskChangeNewFromObj(vm, disk-src, NULL, + disk-info.alias, + VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START); +if (event) +qemuDomainEventQueue(driver, event); + VIR_FREE(disk-src); nextDisk++; } else { if (bitmap disk-info.bootIndex) ignore_value(virBitmapSetBit(bitmap, disk-info.bootIndex - 1)); +event = virDomainEventDiskChangeNewFromObj(vm, disk-src, NULL, + disk-info.alias, + VIR_DOMAIN_EVENT_HARDDISK_DROP_MISSING_ON_START); +if (event) +qemuDomainEventQueue(driver, event); + virDomainDiskDefFree(disk); if (VIR_DELETE_ELEMENT(def-disks, nextDisk, def-ndisks) 0) goto cleanup; -- 1.7.11.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/4] conf: add startupPolicy attribute for harddisk
Add startupPolicy attribute policy for harddisk with type file, block and dir. The network type disk is still not supported. --- docs/formatdomain.html.in | 9 ++--- docs/schemas/domaincommon.rng | 6 ++ src/conf/domain_conf.c| 19 +-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8a3c3b7..15b27af 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1450,8 +1450,8 @@ For a file disk type which represents a cdrom or floppy (the codedevice/code attribute), it is possible to define policy what to do with the disk if the source file is not accessible. -This is done by the codestartupPolicy/code attribute, accepting -these values: +This is done by the codestartupPolicy/code attribute +(span class=sinceSince 0.9.7/span), accepting these values: table class=top_table tr td mandatory /td @@ -1467,7 +1467,10 @@ td drop if missing at any start attempt /td /tr /table -span class=sinceSince 0.9.7/span +span class=sinceSince 1.0.4/span, the codestartupPolicy/code is extended +to support hard disks besides cdrom and floppy. However, the disk of network +type is still not reached. For the guest which is using per-device codeboot/code +element, the boot devices will be reordered after dropping its bootable disks. /dd dtcodemirror/code/dt dd diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 9792065..44486d4 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1048,6 +1048,9 @@ ref name=absFilePath/ /attribute optional + ref name=startupPolicy/ +/optional +optional ref name='devSeclabel'/ /optional /element @@ -1065,6 +1068,9 @@ attribute name=dir ref name=absFilePath/ /attribute +optional + ref name=startupPolicy/ +/optional empty/ /element /optional diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3278e9c..177faaa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4044,7 +4044,6 @@ virDomainDiskDefParseXML(virCapsPtr caps, switch (def-type) { case VIR_DOMAIN_DISK_TYPE_FILE: source = virXMLPropString(cur, file); -startupPolicy = virXMLPropString(cur, startupPolicy); break; case VIR_DOMAIN_DISK_TYPE_BLOCK: source = virXMLPropString(cur, dev); @@ -4137,6 +4136,8 @@ virDomainDiskDefParseXML(virCapsPtr caps, goto error; } +startupPolicy = virXMLPropString(cur, startupPolicy); + /* People sometimes pass a bogus '' source path when they mean to omit the source element completely (e.g. CDROM without media). This is @@ -4674,11 +4675,10 @@ virDomainDiskDefParseXML(virCapsPtr caps, goto error; } -if (def-device != VIR_DOMAIN_DISK_DEVICE_CDROM -def-device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { +if (def-type == VIR_DOMAIN_DISK_TYPE_NETWORK) { virReportError(VIR_ERR_INVALID_ARG, - _(Setting disk %s is allowed only for - cdrom or floppy), + _(Setting disk %s is not allowed for + disk of network type), startupPolicy); goto error; } @@ -12838,6 +12838,9 @@ virDomainDiskDefFormat(virBufferPtr buf, case VIR_DOMAIN_DISK_TYPE_BLOCK: virBufferEscapeString(buf, source dev='%s', def-src); +if (def-startupPolicy) +virBufferEscapeString(buf, startupPolicy='%s', + startupPolicy); if (def-nseclabels) { virBufferAddLit(buf, \n); virBufferAdjustIndent(buf, 8); @@ -12850,8 +12853,12 @@ virDomainDiskDefFormat(virBufferPtr buf, } break; case VIR_DOMAIN_DISK_TYPE_DIR: -virBufferEscapeString(buf, source dir='%s'/\n, +virBufferEscapeString(buf, source dir='%s', def-src); +if (def-startupPolicy) +virBufferEscapeString(buf, startupPolicy='%s', + startupPolicy); +virBufferAddLit(buf, /\n); break; case
[libvirt] [PATCH v2 2/4] util: add two functions to find last set or unset bit in bitmap
virBitmapNextLastSetBit: Search for the last set bit before certain position. virBitmapNextLastSetBit: Search for the last clear bit before certain position. --- src/libvirt_private.syms | 2 + src/util/virbitmap.c | 96 src/util/virbitmap.h | 6 +++ tests/virbitmaptest.c| 51 - 4 files changed, 154 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5cad990..a17465a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1045,6 +1045,8 @@ virBitmapNew; virBitmapNewCopy; virBitmapNewData; virBitmapNextClearBit; +virBitmapNextLastClearBit; +virBitmapNextLastSetBit; virBitmapNextSetBit; virBitmapParse; virBitmapSetAll; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 21509ac..bb677db 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -50,6 +50,21 @@ struct _virBitmap { #define VIR_BITMAP_BIT_OFFSET(b) ((b) % VIR_BITMAP_BITS_PER_UNIT) #define VIR_BITMAP_BIT(b) (1UL VIR_BITMAP_BIT_OFFSET(b)) +/* helper function to get last set bit in long integer */ +static int +flsl(long mask) +{ +int bit = VIR_BITMAP_BITS_PER_UNIT; + +if (mask == 0) +return 0; + +for (; !(mask 1UL (VIR_BITMAP_BITS_PER_UNIT - 1)); bit--) { +mask = (unsigned long)mask 1; +} + +return bit; +} /** * virBitmapNew: @@ -632,6 +647,46 @@ virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos) } /** + * virBitmapNextLastSetBit + * @bitmap: the bitmap + * @pos: the position before which to search for a set bit + * + * Search for the last set bit before position @pos in bitmap @bitmap. + * @pos can be -1 to search for the last set bit. Position starts + * at bitmap-max_bit. + */ + +ssize_t +virBitmapNextLastSetBit(virBitmapPtr bitmap, ssize_t pos) +{ +ssize_t nl; +size_t nb; +unsigned long bits; + +if (pos 0) +pos = bitmap-max_bit; + +pos--; + +if (pos 0 || pos = bitmap-max_bit) +return -1; + +nl = pos / VIR_BITMAP_BITS_PER_UNIT; +nb = pos % VIR_BITMAP_BITS_PER_UNIT; + +bits = bitmap-map[nl] -1UL (VIR_BITMAP_BITS_PER_UNIT - nb - 1); + +while (bits == 0 --nl = 0) { +bits = bitmap-map[nl]; +} + +if (bits == 0) +return -1; + +return flsl(bits) - 1 + nl * VIR_BITMAP_BITS_PER_UNIT; +} + +/** * virBitmapNextClearBit: * @bitmap: the bitmap * @pos: the position after which to search for a clear bit @@ -679,6 +734,47 @@ virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t pos) return ffsl(bits) - 1 + nl * VIR_BITMAP_BITS_PER_UNIT; } +/** + * virBitmapNextLastClearBit: + * @bitmap: the bitmap + * @pos: the position before which to search for a clear bit + * + * Search for the last clear bit before position @pos in bitmap @bitmap. + * @pos can be -1 to search for the last clear bit. Position starts + * at bitmap-max_bit. + * + * Returns the position of the found bit, or -1 if no bit found. + */ +ssize_t +virBitmapNextLastClearBit(virBitmapPtr bitmap, ssize_t pos) +{ +ssize_t nl; +size_t nb; +unsigned long bits; + +if (pos 0) +pos = bitmap-max_bit; + +pos--; + +if (pos 0 || pos = bitmap-max_bit) +return -1; + +nl = pos / VIR_BITMAP_BITS_PER_UNIT; +nb = pos % VIR_BITMAP_BITS_PER_UNIT; + +bits = ~bitmap-map[nl] -1UL (VIR_BITMAP_BITS_PER_UNIT - nb - 1); + +while (bits == 0 --nl = 0) { +bits = ~bitmap-map[nl]; +} + +if (bits == 0) +return -1; + +return flsl(bits) - 1 + nl * VIR_BITMAP_BITS_PER_UNIT; +} + /* Return the number of bits currently set in the map. */ size_t virBitmapCountBits(virBitmapPtr bitmap) diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 044c7a6..d650e1f 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -103,9 +103,15 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap) ssize_t virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos) ATTRIBUTE_NONNULL(1); +ssize_t virBitmapNextLastSetBit(virBitmapPtr bitmap, ssize_t pos) +ATTRIBUTE_NONNULL(1); + ssize_t virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t pos) ATTRIBUTE_NONNULL(1); +ssize_t virBitmapNextLastClearBit(virBitmapPtr bitmap, ssize_t pos) +ATTRIBUTE_NONNULL(1); + size_t virBitmapCountBits(virBitmapPtr bitmap) ATTRIBUTE_NONNULL(1); diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 95d010a..f0a3086 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -161,7 +161,9 @@ error: return ret; } -/* test for virBitmapNextSetBit, virBitmapNextClearBit */ +/* test for virBitmapNextSetBit, virBitmapNextClearBit + * virBitmapNextLastSetBit, virBitmapNextLastClearBit + */ static int test4(const void *data ATTRIBUTE_UNUSED) { const char *bitsString = 0, 2-4, 6-10, 12, 14-18, 20, 22, 25; @@ -193,9 +195,21 @@ static int test4(const void *data ATTRIBUTE_UNUSED) if
[libvirt] [PATCH v2 3/4] qemu: drop disk definition if missing and reorder per-device boot sequence
With 'optional' startupPolicy set, when one or more disk are missing, the qemu process drops their definitions and bootups the vm. When the vm is using per-device boot elements, then we need to reorder them in order to perform migrate successfully if necessary. During the reordering, it uses virBitmapNextLastSetBit to find the last set bit. --- src/conf/domain_conf.c | 2 ++ src/conf/domain_conf.h | 1 + src/qemu/qemu_domain.c | 90 ++ 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 177faaa..069e702 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10992,6 +10992,8 @@ virDomainDefParseXML(virCapsPtr caps, if (virDomainDefAddImplicitControllers(def) 0) goto error; +/* Save the valid number of per-device boot */ +def-os.nBootPerDevs = bootMapSize; virBitmapFree(bootMap); return def; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 96f11ba..362f645 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1543,6 +1543,7 @@ struct _virDomainOSDef { char *machine; size_t nBootDevs; int bootDevs[VIR_DOMAIN_BOOT_LAST]; +unsigned long nBootPerDevs; /* enum virDomainBootMenu */ int bootmenu; char *init; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c79b05d..4594b2c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1791,30 +1791,89 @@ cleanup: virObjectUnref(cfg); } +/* Reorder devices with per-device boot, make them contiguous */ +static int +qemuDomainPerDevicesBootReorder(virDomainDefPtr def, +virBitmapPtr bitmap) +{ +size_t count; +size_t n; +int i = -1; + +if (bitmap == NULL) +return 0; + +count = virBitmapCountBits(bitmap); + +while (count count--) { +i = virBitmapNextLastSetBit(bitmap, i); +for (n = 0 ; n def-ndisks ; n++) { +virDomainDiskDefPtr disk = def-disks[n]; +if (disk-info.bootIndex i + 1) +disk-info.bootIndex -= 1; +} + +for (n = 0 ; n def-nnets ; n++) { +virDomainNetDefPtr net = def-nets[n]; +if (net-info.bootIndex i + 1) +net-info.bootIndex -= 1; +} + +for (n = 0 ; n def-nhostdevs ; n++) { +virDomainHostdevDefPtr hostdev = def-hostdevs[n]; +if (hostdev-info-bootIndex i + 1) +hostdev-info-bootIndex -= 1; +} + +for (n = 0 ; n def-nredirdevs ; n++) { +virDomainRedirdevDefPtr redirdev = def-redirdevs[n]; +if (redirdev-info.bootIndex i + 1) +redirdev-info.bootIndex -= 1; +} +} + +return 0; +} + int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, virDomainObjPtr vm, bool cold_boot) { int ret = -1; -int i; +size_t i; virDomainDiskDefPtr disk; char uuid[VIR_UUID_STRING_BUFLEN]; virDomainEventPtr event = NULL; +virDomainDefPtr def = vm-def; +size_t count = def-ndisks; +unsigned long bootMapSize = def-os.nBootPerDevs; +size_t nextDisk = 0; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); +virBitmapPtr bitmap = NULL; + +virUUIDFormat(def-uuid, uuid); -virUUIDFormat(vm-def-uuid, uuid); +if (bootMapSize) { +if (!(bitmap = virBitmapNew(bootMapSize))) { +virReportOOMError(); +goto cleanup; +} +} -for (i = 0; i vm-def-ndisks; i++) { -disk = vm-def-disks[i]; +for (i = 0; i count; i++) { +disk = def-disks[nextDisk]; -if (!disk-startupPolicy || !disk-src) +if (!disk-startupPolicy || !disk-src) { +nextDisk++; continue; +} if (virFileAccessibleAs(disk-src, F_OK, cfg-user, cfg-group) = 0) { /* disk accessible */ +nextDisk++; continue; } @@ -1846,20 +1905,37 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, VIR_DEBUG(Dropping disk '%s' on domain '%s' (UUID '%s') due to inaccessible source '%s', - disk-dst, vm-def-name, uuid, disk-src); + disk-dst, def-name, uuid, disk-src); event = virDomainEventDiskChangeNewFromObj(vm, disk-src, NULL, disk-info.alias, VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START); if (event) qemuDomainEventQueue(driver, event); -VIR_FREE(disk-src); +/* For CDROM and Floppy disk, only drop source path. + * For Hard disk, drop its definition. + */ +if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM || +disk-device ==
[libvirt] [PATCH v2 0/4]Add startupPolicy attribute support for hard disks
v1 to v2: added relax schema for disk of block and dir type removed original patch 3/5. The set of patches is trying to add 'startupPolicy' attribute support to the source element of hard disks. Policy levels are using the mandatory, requisite, optional levels as originally documented. For the 'optional' policy, there is a little difference from CDROM and Floppy which only drop its source path, for disks, if missing, the checking function will drop their definitions, because qemu doesn't allow missing source path for hard disk. If guest is using per-device boot element for its devices, after dropping one or more bootable device, the boot order will not be contiguous, the way here I use is to reorder them to make them contiguous. In this way, I introduce two new bit-operating functions virBitmapNextLastSetBit: Search for the last set bit before certain position. virBitmapNextLastClearBit: Search for the last clear bit before certain position. Guannan Ren [PATCH v2 1/4] conf: add startupPolicy attribute for harddisk [PATCH v2 2/4] util: add two functions to find last set or unset bit in bitmap [PATCH v2 3/4] qemu: drop disk definition if missing and reorder per-device boot sequence [PATCH v2 4/4] event: add hard disk dropping event reason enum docs/formatdomain.html.in | 9 ++--- docs/schemas/domaincommon.rng | 6 ++ include/libvirt/libvirt.h.in | 1 + src/conf/domain_conf.c| 21 +++-- src/conf/domain_conf.h| 1 + src/libvirt_private.syms | 2 ++ src/qemu/qemu_domain.c| 106 +++--- src/util/virbitmap.c | 96 src/util/virbitmap.h | 6 ++ tests/virbitmaptest.c | 51 ++- 10 files changed, 278 insertions(+), 21 deletions(-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/7] Add 'nbd' as a valid filesystem driver type
On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com The filesystem element can now accept a driver type='nbd'/ as an alternative to 'loop'. The benefit of NBD is support for non-raw disk image formats. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) ACK John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/7] Do not prematurely close loop devices in LXC controller
On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com The LXC controller is closing loop devices as soon as the container has started. This is fine if the loop device was setup as a mounted filesystem, but if we're just passing through the loop device as a disk, nothing else is keeping it open. Thus we must keep the loop device FDs open for as long the libvirt_lxc process is running. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/lxc/lxc_controller.c | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index c433fb1..9545df3 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -199,22 +199,12 @@ error: } -static int virLXCControllerCloseLoopDevices(virLXCControllerPtr ctrl, -bool force) +static int virLXCControllerCloseLoopDevices(virLXCControllerPtr ctrl) { size_t i; -for (i = 0 ; i ctrl-nloopDevs ; i++) { -if (force) { -VIR_FORCE_CLOSE(ctrl-loopDevFds[i]); -} else { -if (VIR_CLOSE(ctrl-loopDevFds[i]) 0) { -virReportSystemError(errno, %s, - _(Unable to close loop device)); -return -1; -} -} -} +for (i = 0 ; i ctrl-nloopDevs ; i++) +VIR_FORCE_CLOSE(ctrl-loopDevFds[i]); return 0; } @@ -1616,10 +1606,6 @@ virLXCControllerRun(virLXCControllerPtr ctrl) /* Now the container is fully setup... */ -/* ...we can close the loop devices... */ -if (virLXCControllerCloseLoopDevices(ctrl, false) 0) -goto cleanup; - /* ...and reduce our privileges */ if (lxcControllerClearCapabilities() 0) goto cleanup; Doesn't the call to virLXCControllerCloseLoopDevices() in virLXCControllerStopInit() need to lose the , true parameter? John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/7] Support NBD backed disks/filesystems in LXC driver
On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com The LXC driver can already configure disk or filesystem devices to use the loop device. This extends it to also allow for use of the NBD device, to support non-raw formats. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/lxc/lxc_controller.c | 64 ++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 8f3ca6a..c433fb1 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -403,6 +403,46 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk) } +static int virLXCControllerSetupNBDDeviceFS(virDomainFSDefPtr fs) +{ +char *dev; + +if (virFileNBDDeviceAssociate(fs-src, dev, + !!fs-readonly) 0) +return -1; + +/* + * We now change it into a block device type, so that + * the rest of container setup 'just works' + */ +fs-type = VIR_DOMAIN_DISK_TYPE_BLOCK; +VIR_FREE(fs-src); +fs-src = dev; + +return 0; +} + + +static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk) +{ +char *dev; + +if (virFileNBDDeviceAssociate(disk-src, dev, + !!disk-readonly) 0) +return -1; + +/* + * We now change it into a block device type, so that + * the rest of container setup 'just works' + */ +disk-type = VIR_DOMAIN_DISK_TYPE_BLOCK; +VIR_FREE(disk-src); +disk-src = dev; + +return 0; +} + + static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) { size_t i; @@ -435,6 +475,9 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) goto cleanup; } ctrl-loopDevFds[ctrl-nloopDevs - 1] = fd; +} else if (fs-fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_NBD) { +if (virLXCControllerSetupNBDDeviceFS(fs) 0) +goto cleanup; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(fs driver %s is not supported), @@ -449,8 +492,14 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) if (disk-type != VIR_DOMAIN_DISK_TYPE_FILE) continue; -if (!disk-driverName || -STREQ(disk-driverName, loop)) { This was if no driverName or if driverName is loop, then make sure RAW or NONE for format... That logic doesn't seem to change with the new checks; however... +/* If no driverName is set, we prefer 'loop' for + * dealing with raw or undefined formats. Only + * default to 'nbd' for non-raw formats. + */ +if ((disk-driverName STREQ(disk-driverName, loop)) || +(!disk-driverName + (disk-format == VIR_STORAGE_FILE_RAW || + disk-format == VIR_STORAGE_FILE_NONE))) { if (disk-format != VIR_STORAGE_FILE_RAW disk-format != VIR_STORAGE_FILE_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -474,6 +523,17 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) goto cleanup; } ctrl-loopDevFds[ctrl-nloopDevs - 1] = fd; +} else if (!disk-driverName || + STREQ(disk-driverName, nbd)) { if driverName is not provided we fall into here? Which doesn't seem to be what was intended. Seems this should be if driverName nbd... +if (disk-cachemode != VIR_DOMAIN_DISK_CACHE_DEFAULT +disk-cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Disk cache mode %s is not supported), + virDomainDiskCacheTypeToString(disk-cachemode)); +goto cleanup; +} +if (virLXCControllerSetupNBDDeviceDisk(disk) 0) +goto cleanup; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(disk driver %s is not supported), Which potentially causes issues hereif driverName == NULL, right? Also might be good to document the nbd format on the formatdomain page. John John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] gconfig: Add calls to [gs]et_virt_type to domain tests
Setting GVirConfigDomain::virt_type is required for a working domain configuration, using it in the test programs will be helpful if people are using this as a base when starting to use libvirt-gconfig --- examples/config-demo.py| 1 + libvirt-gconfig/tests/test-domain-create.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/examples/config-demo.py b/examples/config-demo.py index 508bbc5..268c439 100644 --- a/examples/config-demo.py +++ b/examples/config-demo.py @@ -3,6 +3,7 @@ from gi.repository import LibvirtGConfig; domain = LibvirtGConfig.Domain.new() +domain.set_virt_type(LibvirtGConfig.DomainVirtType.KVM) domain.set_name(foo) domain.set_memory(1024*1024) # 1 GB domain.set_vcpus(2) diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 20fedc5..e30f643 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -111,6 +111,9 @@ int main(int argc, char **argv) domain = gvir_config_domain_new(); g_assert(domain != NULL); + +gvir_config_domain_set_virt_type(domain, GVIR_CONFIG_DOMAIN_VIRT_KVM); +g_assert(gvir_config_domain_get_virt_type(domain) == GVIR_CONFIG_DOMAIN_VIRT_KVM); gvir_config_domain_set_name(domain, foo); g_str_const_check(gvir_config_domain_get_name(domain), foo); -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 1/4] gconfig: Add GVirConfigStoragePool getters
--- libvirt-gconfig/libvirt-gconfig-storage-pool.c | 143 + libvirt-gconfig/libvirt-gconfig-storage-pool.h | 8 ++ libvirt-gconfig/libvirt-gconfig.sym| 12 +++ 3 files changed, 163 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.c b/libvirt-gconfig/libvirt-gconfig-storage-pool.c index 4ad9fc1..b06c24c 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.c @@ -74,6 +74,25 @@ GVirConfigStoragePool *gvir_config_storage_pool_new_from_xml(const gchar *xml, return GVIR_CONFIG_STORAGE_POOL(object); } +/** + * gvir_config_storage_pool_get_pool_type: + * @pool: a #GVirConfigStoragePool + * + * Gets the type of the pool. + * + * Returns: #Gname of @pool. + */ +GVirConfigStoragePoolType gvir_config_storage_pool_get_pool_type(GVirConfigStoragePool *pool) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), + GVIR_CONFIG_STORAGE_POOL_TYPE_DIR); + +return gvir_config_object_get_attribute_genum(GVIR_CONFIG_OBJECT(pool), + NULL, type, + GVIR_CONFIG_TYPE_STORAGE_POOL_TYPE, + GVIR_CONFIG_STORAGE_POOL_TYPE_DIR); +} + void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool, GVirConfigStoragePoolType type) { @@ -87,6 +106,22 @@ void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool, } /** + * gvir_config_storage_pool_get_name: + * @pool: a #GVirConfigStoragePool + * + * Gets the name of the pool. + * + * Returns: name of @pool. + */ +const char *gvir_config_storage_pool_get_name(GVirConfigStoragePool *pool) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL); + +return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(pool), + name); +} + +/** * gvir_config_storage_pool_set_name: * @name: (allow-none): */ @@ -100,6 +135,22 @@ void gvir_config_storage_pool_set_name(GVirConfigStoragePool *pool, } /** + * gvir_config_storage_pool_get_uuid: + * @pool: a #GVirConfigStoragePool + * + * Gets the unique identifier for @pool. + * + * Returns: unique identifier for @pool. + */ +const char *gvir_config_storage_pool_get_uuid(GVirConfigStoragePool *pool) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL); + +return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(pool), + uuid); +} + +/** * gvir_config_storage_pool_set_uuid: * @uuid: (allow-none): */ @@ -112,6 +163,22 @@ void gvir_config_storage_pool_set_uuid(GVirConfigStoragePool *pool, uuid, uuid); } +/** + * gvir_config_storage_pool_get_capacity: + * @pool: a #GVirConfigStoragePool + * + * Gets the total storage capacity for the pool. + * + * Returns: total storage capacity in bytes. + */ +guint64 gvir_config_storage_pool_get_capacity(GVirConfigStoragePool *pool) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0); + +return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool), + capacity); +} + void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool, guint64 capacity) { @@ -121,6 +188,22 @@ void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool, capacity, capacity); } +/** + * gvir_config_storage_pool_get_allocation: + * @pool: a #GVirConfigStoragePool + * + * Gets the total storage allocation for the pool. + * + * Returns: total storage allocation in bytes. + */ +guint64 gvir_config_storage_pool_get_allocation(GVirConfigStoragePool *pool) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0); + +return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool), + allocation); +} + void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool, guint64 allocation) { @@ -130,6 +213,22 @@ void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool, allocation, allocation); } +/** + * gvir_config_storage_pool_get_available: + * @pool: a #GVirConfigStoragePool + * + * Gets the free space available for allocating new volumes in the pool. + * + * Returns: free space available in bytes. + */ +guint64 gvir_config_storage_pool_get_available(GVirConfigStoragePool *pool) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0); + +return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool), +
[libvirt] [libvirt-glib 2/4] gconfig: Add GVirConfigStoragePoolSource getters
--- .../libvirt-gconfig-storage-pool-source.c | 132 + .../libvirt-gconfig-storage-pool-source.h | 8 ++ libvirt-gconfig/libvirt-gconfig.sym| 9 ++ libvirt-gconfig/tests/test-domain-create.c | 3 + 4 files changed, 152 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c index e3967ad..ad8b28d 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c @@ -71,6 +71,22 @@ GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new_from_xml(const return GVIR_CONFIG_STORAGE_POOL_SOURCE(object); } +/** + * gvir_config_storage_pool_source_get_adapter: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by a SCSI adapter, returns the SCSI adapter name + * + * Returns: the SCSI adapter name. + */ +const char *gvir_config_storage_pool_source_get_adapter(GVirConfigStoragePoolSource *source) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); +return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), +adapter, +name); +} + void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *source, const char *adapter) { @@ -84,6 +100,23 @@ void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *so g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_device_path: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by a physical device, returns the path to the block + * device node + * + * Returns: fully qualified path to the block device node. + */ +const char *gvir_config_storage_pool_source_get_device_path(GVirConfigStoragePoolSource *source) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); +return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), +device, +path); +} + void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource *source, const char *device_path) { @@ -97,6 +130,22 @@ void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_directory: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by a directory, returns the path to the backing directory + * + * Returns: path to the directory backing directory. + */ +const char *gvir_config_storage_pool_source_get_directory(GVirConfigStoragePoolSource *source) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); +return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), +directory, +path); +} + void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource *source, const char *directory) { @@ -110,6 +159,24 @@ void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource * g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_format: + * @source: a #GVirConfigStoragePoolSource + * + * Provides information about the format of the pool. This format is + * backend-specific but is typically used to indicate filesystem type, or + * network filesystem type, or partition table type, or LVM metadata type. + * + * Returns: the storage pool format. + */ +const char *gvir_config_storage_pool_source_get_format(GVirConfigStoragePoolSource *source) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); +return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), +format, +type); +} + void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *source, const char *format) { @@ -123,6 +190,23 @@ void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *sou g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_host: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by storage from remote server, returns the hostname + * of the remote server. + * + * Returns: hostname or IP address of the remote server. + */ +const char *gvir_config_storage_pool_source_get_host(GVirConfigStoragePoolSource *source) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); +return
[libvirt] [libvirt-glib 3/4] gconfig: Add GvirConfigStoragePoolTarget getters
--- .../libvirt-gconfig-storage-pool-target.c | 39 ++ .../libvirt-gconfig-storage-pool-target.h | 2 ++ libvirt-gconfig/libvirt-gconfig.sym| 3 ++ libvirt-gconfig/tests/test-domain-create.c | 4 +++ 4 files changed, 48 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c index c83145c..f76b26c 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c @@ -72,6 +72,23 @@ GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new_from_xml(const } /** + * gvir_config_storage_pool_target_get_path: + * @target: a #GVirConfigStoragePoolTarget + * + * Provides the location at which the storage pool associated with @target + * will be mapped into the local filesystem namespace. + * + * Returns: local filesystem path the storage pool is mapped at. + */ +const char *gvir_config_storage_pool_target_get_path(GVirConfigStoragePoolTarget *target) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target), NULL); + +return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(target), + path); +} + +/** * gvir_config_storage_pool_target_set_path: * @path: (allow-none): */ @@ -85,6 +102,28 @@ void gvir_config_storage_pool_target_set_path(GVirConfigStoragePoolTarget *targe } /** + * gvir_config_storage_pool_target_get_permissions: + * @target: a #GVirConfigStoragePoolTarget + * + * Gets the permissions associated with @target + * + * Returns: (transfer full): a new #GVirConfigStoragePoolPermissions instance. + */ +GVirConfigStoragePermissions *gvir_config_storage_pool_target_get_permissions(GVirConfigStoragePoolTarget *target) +{ +GVirConfigObject *object; + +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target), NULL); + +object = gvir_config_object_get_child_with_type +(GVIR_CONFIG_OBJECT(target), + permissions, + GVIR_CONFIG_TYPE_STORAGE_PERMISSIONS); + +return GVIR_CONFIG_STORAGE_PERMISSIONS(object); +} + +/** * gvir_config_storage_pool_perms_set_permissions: * @perms: (allow-none): */ diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h index 031abe2..ca6602d 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h @@ -63,8 +63,10 @@ GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new(void); GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new_from_xml(const gchar *xml, GError **error); +const char *gvir_config_storage_pool_target_get_path(GVirConfigStoragePoolTarget *target); void gvir_config_storage_pool_target_set_path(GVirConfigStoragePoolTarget *target, const char *path); +GVirConfigStoragePermissions *gvir_config_storage_pool_target_get_permissions(GVirConfigStoragePoolTarget *target); void gvir_config_storage_pool_target_set_permissions(GVirConfigStoragePoolTarget *target, GVirConfigStoragePermissions *perms); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 49072dd..4456487 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -531,6 +531,9 @@ LIBVIRT_GCONFIG_0.1.7 { gvir_config_storage_pool_source_get_name; gvir_config_storage_pool_source_get_product; gvir_config_storage_pool_source_get_vendor; + + gvir_config_storage_pool_target_get_path; + gvir_config_storage_pool_target_get_permissions; } LIBVIRT_GCONFIG_0.1.6; # define new API here using predicted next version number diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index f7cb076..88bfbfb 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -422,6 +422,10 @@ int main(int argc, char **argv) gvir_config_storage_pool_set_target(pool, pool_target); g_object_unref(G_OBJECT(pool_target)); +pool_target = gvir_config_storage_pool_get_target(pool); +g_str_const_check(gvir_config_storage_pool_target_get_path(pool_target), /dev/disk/by-path); +g_object_unref(G_OBJECT(pool_target)); + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(pool)); g_print(%s\n\n, xml); g_free(xml); -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 4/4] gconfig: Add GvirConfigStoragePermission getters
--- .../libvirt-gconfig-storage-permissions.c | 63 ++ .../libvirt-gconfig-storage-permissions.h | 4 ++ libvirt-gconfig/libvirt-gconfig.sym| 5 ++ libvirt-gconfig/tests/test-domain-create.c | 6 +++ 4 files changed, 78 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c index e583211..066ee11 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c @@ -70,6 +70,22 @@ GVirConfigStoragePermissions *gvir_config_storage_permissions_new_from_xml(const return GVIR_CONFIG_STORAGE_PERMISSIONS(object); } +/** + * gvir_config_storage_permissions_get_group: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the numeric group ID associated with @perms. + * + * Returns: numeric group ID + */ +guint gvir_config_storage_permissions_get_group(GVirConfigStoragePermissions *perms) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), 0); + +return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(perms), + group); +} + void gvir_config_storage_permissions_set_group(GVirConfigStoragePermissions *perms, guint group) { @@ -80,6 +96,21 @@ void gvir_config_storage_permissions_set_group(GVirConfigStoragePermissions *per } /** + * gvir_config_storage_permissions_get_label: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the MAC label string associated with @perms. + * + * Returns: MAC label string. + */ +const char *gvir_config_storage_permissions_get_label(GVirConfigStoragePermissions *perms) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), NULL); + +return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(perms), + label); +} +/** * gvir_config_storage_permissions_set_label: * @label: (allow-none): */ @@ -92,6 +123,22 @@ void gvir_config_storage_permissions_set_label(GVirConfigStoragePermissions *per label, label); } +/** + * gvir_config_storage_permissions_get_mode: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the octal permission set associated with @perms. + * + * Returns: permission set + */ +guint gvir_config_storage_permissions_get_mode(GVirConfigStoragePermissions *perms) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), 0); + +return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(perms), + mode); +} + void gvir_config_storage_permissions_set_mode(GVirConfigStoragePermissions *perms, guint mode) { @@ -101,6 +148,22 @@ void gvir_config_storage_permissions_set_mode(GVirConfigStoragePermissions *perm mode, mode); } +/** + * gvir_config_storage_permissions_get_owner: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the numeric user ID associated with @perms. + * + * Returns: numeric user ID. + */ +guint gvir_config_storage_permissions_get_owner(GVirConfigStoragePermissions *perms) +{ +g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), 0); + +return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(perms), + owner); +} + void gvir_config_storage_permissions_set_owner(GVirConfigStoragePermissions *perms, guint owner) { diff --git a/libvirt-gconfig/libvirt-gconfig-storage-permissions.h b/libvirt-gconfig/libvirt-gconfig-storage-permissions.h index 79f1d4b..79fbe85 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-permissions.h +++ b/libvirt-gconfig/libvirt-gconfig-storage-permissions.h @@ -63,12 +63,16 @@ GVirConfigStoragePermissions *gvir_config_storage_permissions_new(void); GVirConfigStoragePermissions *gvir_config_storage_permissions_new_from_xml(const gchar *xml, GError **error); +guint gvir_config_storage_permissions_get_group(GVirConfigStoragePermissions *perms); void gvir_config_storage_permissions_set_group(GVirConfigStoragePermissions *perms, guint group); +const char *gvir_config_storage_permissions_get_label(GVirConfigStoragePermissions *perms); void gvir_config_storage_permissions_set_label(GVirConfigStoragePermissions *perms, const char *label); +guint gvir_config_storage_permissions_get_mode(GVirConfigStoragePermissions *perms); void gvir_config_storage_permissions_set_mode(GVirConfigStoragePermissions *perms, guint
Re: [libvirt] IPv6 migration
On Mon, Mar 11, 2013 at 19:40:52 +0100, Ján Tomko wrote: Hello. We can only tell QEMU on the destination to listen either on IPv6 or on IPv4. If we're supplied with a numeric v6 address, that's the only thing we need to know to set the listen address to [::]. For hostnames, we can either assume this based on how it resolves by default on the destination (we keep trying all the resolved addresses on the source, but this might break a few cases), which John found disgusting, so that leaves user input: How about a VIR_DOMAIN_MIGRATE_IPV6 flag, depending on which we set the listen address on the destination and creating a new function virNetSocketNewConnectTCPHints, where we would add IPv4/IPv6 hint based on the presence/absence of this flag? Yeah, I think using an explicit flag would be the best approach. As we learnt several times, implementing automagic behavior is too fragile and leads to ugly code and confusion. IIUC, we would tell QEMU to listen on :: iff either migrateuri uses IPv6 address explicitly or VIR_DOMAIN_MIGRATE_IPV6 flag is set. In all other cases, 0.0.0.0 address will be passed to QEMU. In other words, unless a user takes an explicit action, migration will use IPv4 regardless on libvirt version. Would it be better to auto-add this flag for numeric addresses, or just check for them both in the Prepare phase on the dest (and set listen_addr accordingly) and before connecting from the source, so we don't use the IPv4 hint (in case we wanted to use the partial fix for just numeric addresses for older libvirt). I don't think auto-adding the flag is wise. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/7] Do not prematurely close loop devices in LXC controller
On Tue, Mar 19, 2013 at 10:17:59AM -0400, John Ferlan wrote: On 03/15/2013 12:32 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com The LXC controller is closing loop devices as soon as the container has started. This is fine if the loop device was setup as a mounted filesystem, but if we're just passing through the loop device as a disk, nothing else is keeping it open. Thus we must keep the loop device FDs open for as long the libvirt_lxc process is running. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/lxc/lxc_controller.c | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index c433fb1..9545df3 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -199,22 +199,12 @@ error: } -static int virLXCControllerCloseLoopDevices(virLXCControllerPtr ctrl, -bool force) +static int virLXCControllerCloseLoopDevices(virLXCControllerPtr ctrl) { size_t i; -for (i = 0 ; i ctrl-nloopDevs ; i++) { -if (force) { -VIR_FORCE_CLOSE(ctrl-loopDevFds[i]); -} else { -if (VIR_CLOSE(ctrl-loopDevFds[i]) 0) { -virReportSystemError(errno, %s, - _(Unable to close loop device)); -return -1; -} -} -} +for (i = 0 ; i ctrl-nloopDevs ; i++) +VIR_FORCE_CLOSE(ctrl-loopDevFds[i]); return 0; } @@ -1616,10 +1606,6 @@ virLXCControllerRun(virLXCControllerPtr ctrl) /* Now the container is fully setup... */ -/* ...we can close the loop devices... */ -if (virLXCControllerCloseLoopDevices(ctrl, false) 0) -goto cleanup; - /* ...and reduce our privileges */ if (lxcControllerClearCapabilities() 0) goto cleanup; Doesn't the call to virLXCControllerCloseLoopDevices() in virLXCControllerStopInit() need to lose the , true parameter? Yes, of course :-) Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] Fix /pool/storage/directory@path documentation
Because of a wrong copy and paste, the documentation was saying that 'path' is the path to a block device node while it's a path to a directory. --- Pushed under the trivial rule docs/formatstorage.html.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 8ac7ab1..49ae818 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -84,7 +84,7 @@ dtcodedirectory/code/dt ddProvides the source for pools backed by directories. May only occur once. Contains a single attribute codepath/code -which is the fully qualified path to the block device node. +which is the fully qualified path to the backing directory. span class=sinceSince 0.4.1/span/dd dtcodeadapter/code/dt ddProvides the source for pools backed by SCSI adapters. May -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] Fix /pool/storage/name documentation
There was a 2 word sentence 'remote server' which is a left-over from copy and paste. --- Pushed under the trivial rule. docs/formatstorage.html.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 49ae818..9b68738 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -101,7 +101,7 @@ dtcodename/code/dt ddProvides the source for pools backed by storage from a named element (e.g., a logical volume group name). -remote server. Contains a string identifier. +Contains a string identifier. span class=sinceSince 0.4.5/span/dd dtcodeformat/code/dt ddProvides information about the format of the pool. This -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-designer 1/2] Fix libvirt caps - libosinfo platform short id mapping
On Tue, Mar 19, 2013 at 10:46:35AM +0100, Christophe Fergeau wrote: The code was building an id starting with kvm- while libosinfo qemu description uses qemu-kvm-. Also, starting from qemu 1.2.0, there is no separate qemu-kvm tarball. guess_platform_from_connect is starting to be a bit magic, it may be better to add a machine attribute to libosinfo platform description and to use this to improve the matching between libosinfo data and libvirt caps. I've never been able to think up a satisfactory way to do the mapping yet, without black magic like this. The trick is we don't want to tie libosinfo to libvirt concepts directly, since we want it to be generally useful to anyone doing virt stuff regardless of whether they use libvirt. diff --git a/examples/virtxml.c b/examples/virtxml.c index 09f49cf..a68843d 100644 --- a/examples/virtxml.c +++ b/examples/virtxml.c @@ -442,13 +442,13 @@ guess_platform_from_connect(GVirConnection *conn) } /* do some mappings: - * QEMU - kvm + * QEMU - qemu-kvm * Xen - xen */ type = g_ascii_strdown(hv_type, -1); -if (g_str_equal(type, qemu)) { +if (g_str_equal(type, qemu) ver = 1002000) { g_free(type); -type = g_strdup(kvm); +type = g_strdup(qemu-kvm); } ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-designer 1/2] Fix libvirt caps - libosinfo platform short id mapping
On Tue, Mar 19, 2013 at 03:24:22PM +, Daniel P. Berrange wrote: On Tue, Mar 19, 2013 at 10:46:35AM +0100, Christophe Fergeau wrote: The code was building an id starting with kvm- while libosinfo qemu description uses qemu-kvm-. Also, starting from qemu 1.2.0, there is no separate qemu-kvm tarball. guess_platform_from_connect is starting to be a bit magic, it may be better to add a machine attribute to libosinfo platform description and to use this to improve the matching between libosinfo data and libvirt caps. I've never been able to think up a satisfactory way to do the mapping yet, without black magic like this. The trick is we don't want to tie libosinfo to libvirt concepts directly, since we want it to be generally useful to anyone doing virt stuff regardless of whether they use libvirt. Agreed on not tying too much libosinfo with libvirt concepts. The machine tag seemed acceptable from that perspective as this initially is a qemu concept, so not too deeply tied to libvirt. Alternatively, maybe we can ship some specialized datamaps to transform libosinfo short IDs to something meaningful in a libvirt/... context. Applications could pick the most appropriate one depending on what they are using. Christophe pgpN7t3GVIRFy.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-designer 1/2] Fix libvirt caps - libosinfo platform short id mapping
On Tue, Mar 19, 2013 at 04:54:46PM +0100, Christophe Fergeau wrote: On Tue, Mar 19, 2013 at 03:24:22PM +, Daniel P. Berrange wrote: On Tue, Mar 19, 2013 at 10:46:35AM +0100, Christophe Fergeau wrote: The code was building an id starting with kvm- while libosinfo qemu description uses qemu-kvm-. Also, starting from qemu 1.2.0, there is no separate qemu-kvm tarball. guess_platform_from_connect is starting to be a bit magic, it may be better to add a machine attribute to libosinfo platform description and to use this to improve the matching between libosinfo data and libvirt caps. I've never been able to think up a satisfactory way to do the mapping yet, without black magic like this. The trick is we don't want to tie libosinfo to libvirt concepts directly, since we want it to be generally useful to anyone doing virt stuff regardless of whether they use libvirt. Agreed on not tying too much libosinfo with libvirt concepts. The machine tag seemed acceptable from that perspective as this initially is a qemu concept, so not too deeply tied to libvirt. Alternatively, maybe we can ship some specialized datamaps to transform libosinfo short IDs to something meaningful in a libvirt/... context. Applications could pick the most appropriate one depending on what they are using. Perhaps we should be following the approach we use for detecting ISOs, and match against actual product release strings. Libvirt doesn't expose such info, but we could add an API to expose the full product string and/or version string. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-designer 1/2] Fix libvirt caps - libosinfo platform short id mapping
On Tue, Mar 19, 2013 at 03:58:18PM +, Daniel P. Berrange wrote: Perhaps we should be following the approach we use for detecting ISOs, and match against actual product release strings. Libvirt doesn't expose such info, but we could add an API to expose the full product string and/or version string. Sounds like a good idea. Another way would be for libosinfo to expose some platform_name and platform_version strings with well defined formats, this would allow for the matching to less magic. This is more magic than what you suggest, but has the advantage of not requiring libvirt changes. I might give a try to the regex match approach you suggest. Christophe pgpdBVWWw9E6M.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix --without-libvirtd builds
On Sat, Mar 16, 2013 at 9:11 PM, Doug Goldstein car...@cardoe.com wrote: When building with --without-libvirtd and udev support is detected we will fail to build with the following error: node_device/node_device_udev.c:1608:37: error: unknown type name 'virStateInhibitCallback' --- src/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index 8b591d2..e361a6b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1237,6 +1237,7 @@ libvirt_driver_nodedev_la_CFLAGS = \ libvirt_driver_nodedev_la_LDFLAGS = $(AM_LDFLAGS) libvirt_driver_nodedev_la_LIBADD = +if WITH_LIBVIRTD if WITH_HAL libvirt_driver_nodedev_la_SOURCES += $(NODE_DEVICE_DRIVER_HAL_SOURCES) libvirt_driver_nodedev_la_CFLAGS += $(HAL_CFLAGS) @@ -1247,6 +1248,7 @@ libvirt_driver_nodedev_la_SOURCES += $(NODE_DEVICE_DRIVER_UDEV_SOURCES) libvirt_driver_nodedev_la_CFLAGS += $(UDEV_CFLAGS) $(PCIACCESS_CFLAGS) libvirt_driver_nodedev_la_LIBADD += $(UDEV_LIBS) $(PCIACCESS_LIBS) endif +endif if WITH_DRIVER_MODULES libvirt_driver_nodedev_la_LIBADD += ../gnulib/lib/libgnu.la -- 1.8.1.5 Ping? This is needed for anyone building this way with 1.0.2 through current master. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix --without-libvirtd builds
On 03/16/2013 08:11 PM, Doug Goldstein wrote: When building with --without-libvirtd and udev support is detected we will fail to build with the following error: node_device/node_device_udev.c:1608:37: error: unknown type name 'virStateInhibitCallback' --- src/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] rename tests/conftest.c
To prevent confusion with configure's popular name for a file, rename conftest.c to test_conf.c which is consistent with the invoking test_conf.sh Signed-off-by: Gene Czarcinski g...@czarc.net --- tests/Makefile.am | 8 tests/conftest.c | 48 tests/test_conf.c | 48 tests/test_conf.sh | 2 +- 4 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 tests/conftest.c create mode 100644 tests/test_conf.c diff --git a/tests/Makefile.am b/tests/Makefile.am index d3a7868..837ae93 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -88,7 +88,7 @@ EXTRA_DIST = \ xml2vmxdata \ .valgrind.supp -test_helpers = commandhelper ssh conftest +test_helpers = commandhelper ssh test_conf test_programs = virshtest sockettest \ nodeinfotest virbuftest \ commandtest seclabeltest \ @@ -506,9 +506,9 @@ virshtest_SOURCES = \ testutils.c testutils.h virshtest_LDADD = $(LDADDS) -conftest_SOURCES = \ - conftest.c -conftest_LDADD = $(LDADDS) +test_conf_SOURCES = \ + test_conf.c +test_conf_LDADD = $(LDADDS) nodeinfotest_SOURCES = \ nodeinfotest.c testutils.h testutils.c diff --git a/tests/conftest.c b/tests/conftest.c deleted file mode 100644 index d5467e8..000 --- a/tests/conftest.c +++ /dev/null @@ -1,48 +0,0 @@ -#include config.h - -#include unistd.h -#include stdlib.h -#include stdio.h -#include string.h -#include errno.h -#include virconf.h -#include viralloc.h - -int main(int argc, char **argv) -{ -int ret, exit_code = EXIT_FAILURE; -virConfPtr conf; -int len = 1; -char *buffer = NULL; - -if (argc != 2) { -fprintf(stderr, Usage: %s conf_file\n, argv[0]); -goto cleanup; -} - -if (VIR_ALLOC_N(buffer, len) 0) { -fprintf(stderr, out of memory\n); -goto cleanup; -} -conf = virConfReadFile(argv[1], 0); -if (conf == NULL) { -fprintf(stderr, Failed to process %s\n, argv[1]); -goto cleanup; -} -ret = virConfWriteMem(buffer, len, conf); -if (ret 0) { -fprintf(stderr, Failed to serialize %s back\n, argv[1]); -goto cleanup; -} -virConfFree(conf); -if (fwrite(buffer, 1, len, stdout) != len) { -fprintf(stderr, Write failed: %s\n, strerror(errno)); -goto cleanup; -} - -exit_code = EXIT_SUCCESS; - -cleanup: -VIR_FREE(buffer); -return exit_code; -} diff --git a/tests/test_conf.c b/tests/test_conf.c new file mode 100644 index 000..d5467e8 --- /dev/null +++ b/tests/test_conf.c @@ -0,0 +1,48 @@ +#include config.h + +#include unistd.h +#include stdlib.h +#include stdio.h +#include string.h +#include errno.h +#include virconf.h +#include viralloc.h + +int main(int argc, char **argv) +{ +int ret, exit_code = EXIT_FAILURE; +virConfPtr conf; +int len = 1; +char *buffer = NULL; + +if (argc != 2) { +fprintf(stderr, Usage: %s conf_file\n, argv[0]); +goto cleanup; +} + +if (VIR_ALLOC_N(buffer, len) 0) { +fprintf(stderr, out of memory\n); +goto cleanup; +} +conf = virConfReadFile(argv[1], 0); +if (conf == NULL) { +fprintf(stderr, Failed to process %s\n, argv[1]); +goto cleanup; +} +ret = virConfWriteMem(buffer, len, conf); +if (ret 0) { +fprintf(stderr, Failed to serialize %s back\n, argv[1]); +goto cleanup; +} +virConfFree(conf); +if (fwrite(buffer, 1, len, stdout) != len) { +fprintf(stderr, Write failed: %s\n, strerror(errno)); +goto cleanup; +} + +exit_code = EXIT_SUCCESS; + +cleanup: +VIR_FREE(buffer); +return exit_code; +} diff --git a/tests/test_conf.sh b/tests/test_conf.sh index aa7abf6..2920e28 100755 --- a/tests/test_conf.sh +++ b/tests/test_conf.sh @@ -12,7 +12,7 @@ data_dir=$abs_srcdir/confdata for f in $(cd $data_dir echo *.conf) do i=`expr $i + 1` -$abs_builddir/conftest $data_dir/$f $f-actual +$abs_builddir/test_conf $data_dir/$f $f-actual expected=$data_dir/`echo $f | sed s+\.conf$+\.out+` if compare $expected $f-actual; then ret=0 -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] conftest segfault
On 03/18/2013 01:42 PM, Eric Blake wrote: On 03/16/2013 11:08 PM, Eric Blake wrote: So, it appears the this version of gnulib fixes something important but also causes a segfault when ./configure is run with the new gnulib. What I do not know is if this segfault has any meaning. The segfault DOES have meaning - it means that glibc is broken, but that the brokenness of glibc will not impact the rest of libvirtd. Quit worrying about it. Since libvirt uses gnulib for some/many/most/all of what it needs from libc and gnulib specifically has its own copy/version of regexec.c which has exactly the same patch as the one that goes against glibc, you are correct in saying that libvirt does not suffer from the problem. Maybe something should be done to have configure use gnulib instead of glibc for its tests. You are misunderstanding HOW gnulib works. Gnulib works by injecting tests into configure time, in order to determine whether to stick with glibc or gnulib at compile time. You MUST test glibc, at least once, in order to determine whether glibc is safe to use elsewhere. Getting a SEGV during configure is SUPPOSED to happen, if glibc is buggy, and that is gnulib that injected the code into configure that is forcing the glibc coredump. As for your suggestion of using gnulib at configure time, it IS gnulib that is doing the probe of glibc; we can't link against gnulib until it is built, but we don't know what to build until the gnulib configure-time tests have probed what works and what needs working around. There is nothing to fix in libvirt. Gnulib is working, as designed. OK, understand (finally) ;) One other little thing ... libvirt has a test named conftest ... very confusing in this case. I just may submit a patch to rename that particular test. Yes, a patch to rename the libvirt test would be worthwhile. Done. BTW, if you get a chance could you look at the patch to add ip-route for virtual networks? Gene -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] add a boot option to do strict boot
Applied. Thanks. Regards, Anthony Liguori -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rename tests/conftest.c
On 03/19/2013 12:36 PM, Gene Czarcinski wrote: To prevent confusion with configure's popular name for a file, rename conftest.c to test_conf.c which is consistent with the invoking test_conf.sh Signed-off-by: Gene Czarcinski g...@czarc.net --- tests/Makefile.am | 8 tests/conftest.c | 48 tests/test_conf.c | 48 tests/test_conf.sh | 2 +- 4 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 tests/conftest.c create mode 100644 tests/test_conf.c git rename detection is awesome; your email would be much smaller if you do this step mentioned in HACKING: git config diff.renames true ACK and pushed, plus a tweak to .gitignore to ignore the new test_conf binary. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix --without-libvirtd builds
On Tue, Mar 19, 2013 at 12:58 PM, Eric Blake ebl...@redhat.com wrote: On 03/16/2013 08:11 PM, Doug Goldstein wrote: When building with --without-libvirtd and udev support is detected we will fail to build with the following error: node_device/node_device_udev.c:1608:37: error: unknown type name 'virStateInhibitCallback' --- src/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org Thanks. Pushed to master and latest-maint. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 2/3] qemu: add dtb option supprt
On 03/19/2013 06:24 AM, Daniel P. Berrange wrote: On Thu, Mar 14, 2013 at 12:49:43PM +0800, Olivia Yin wrote: s/supprt/support/ in the subject The dtb option sets the filename for the device tree. If without this option support, -dtb file will be converted into qemu:commandline in domain XML file. For example, '-dtb /media/ram/test.dtb' will be converted into qemu:commandline qemu:arg value='-dtb'/ qemu:arg value='/media/ram/test.dtb'/ /qemu:commandline ACK I will push these soon. - virtio-ccw + virtio-ccw, + dtb, Oops - we let the previous person to touch this enum forget to use a trailing comma. Oh well, not your fault. -if (version = 11000) +if (version = 11000) { virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_HOST); +virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB); +} Doesn't '-dtb' show up in the -help output ? If it does, then it is preferrable to check for that, instead of using a version number based check It does; in fact, it showed up in 1.1 (and NOT in 0.11). Here's what I will squash in: diff --git i/src/qemu/qemu_capabilities.c w/src/qemu/qemu_capabilities.c index 48fd971..50f8084 100644 --- i/src/qemu/qemu_capabilities.c +++ w/src/qemu/qemu_capabilities.c @@ -1087,6 +1087,9 @@ virQEMUCapsComputeCmdFlags(const char *help, if (strstr(help, dump-guest-core=on|off)) virQEMUCapsSet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE); +if (strstr(help, -dtb)) +virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB); + /* * Handling of -incoming arg with varying features * -incoming tcp(kvm = 79, qemu = 0.10.0) @@ -1174,10 +1177,8 @@ virQEMUCapsComputeCmdFlags(const char *help, if (version = 12000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_ROMBAR); -if (version = 11000) { +if (version = 11000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_HOST); -virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB); -} if (version = 1002000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); diff --git i/tests/qemuhelptest.c w/tests/qemuhelptest.c index 1cceffa..059fa86 100644 --- i/tests/qemuhelptest.c +++ w/tests/qemuhelptest.c @@ -339,8 +339,7 @@ mymain(void) QEMU_CAPS_NO_ACPI, QEMU_CAPS_VIRTIO_BLK_SG_IO, QEMU_CAPS_CPU_HOST, -QEMU_CAPS_VNC, -QEMU_CAPS_DTB); +QEMU_CAPS_VNC); DO_TEST(qemu-kvm-0.12.1.2-rhel60, 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -398,8 +397,7 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, QEMU_CAPS_DEVICE_USB_SERIAL, -QEMU_CAPS_DEVICE_USB_NET, -QEMU_CAPS_DTB); +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-kvm-0.12.3, 12003, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -442,8 +440,7 @@ mymain(void) QEMU_CAPS_NO_ACPI, QEMU_CAPS_VIRTIO_BLK_SG_IO, QEMU_CAPS_CPU_HOST, -QEMU_CAPS_VNC, -QEMU_CAPS_DTB); +QEMU_CAPS_VNC); DO_TEST(qemu-kvm-0.13.0, 13000, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -509,8 +506,7 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, QEMU_CAPS_DEVICE_USB_SERIAL, -QEMU_CAPS_DEVICE_USB_NET, -QEMU_CAPS_DTB); +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-kvm-0.12.1.2-rhel61, 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -575,8 +571,7 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, QEMU_CAPS_DEVICE_USB_SERIAL, -QEMU_CAPS_DEVICE_USB_NET, -QEMU_CAPS_DTB); +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-kvm-0.12.1.2-rhel62-beta, 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -648,8 +643,7 @@ mymain(void) QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, -QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DTB); +QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST(qemu-1.0, 100, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -729,8 +723,7 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, QEMU_CAPS_DEVICE_USB_SERIAL, -QEMU_CAPS_DEVICE_USB_NET, -QEMU_CAPS_DTB); +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-1.1.0, 1001000, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list
Re: [libvirt] [PATCH v5 2/3] qemu: add dtb option supprt
On 03/13/2013 10:49 PM, Olivia Yin wrote: The dtb option sets the filename for the device tree. If without this option support, -dtb file will be converted into qemu:commandline in domain XML file. For example, '-dtb /media/ram/test.dtb' will be converted into qemu:commandline qemu:arg value='-dtb'/ qemu:arg value='/media/ram/test.dtb'/ /qemu:commandline +++ b/src/qemu/qemu_command.c @@ -5984,6 +5984,8 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArgList(cmd, -initrd, def-os.initrd, NULL); if (def-os.cmdline) virCommandAddArgList(cmd, -append, def-os.cmdline, NULL); +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB) def-os.dtb) +virCommandAddArgList(cmd, -dtb, def-os.dtb, NULL); This silently ignores def-os.dtb if set but qemu is too old. Instead, we should error out on the unsupported combination. +++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-system-ppc -S -M ppce500v2 -m 256 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -kernel /media/ram/uImage -initrd /media/ram/ramdisk -append 'root=/dev/ram rw console=ttyS0,115200' -dtb /media/ram/test.dtb -usb -net none -serial pty -parallel none Sheesh, this line is long. Backslash-newline is your friend. In addition to what I'm squashing after Dan's comments, I'm adding this: diff --git i/src/qemu/qemu_command.c w/src/qemu/qemu_command.c index 0b56726..8626b62 100644 --- i/src/qemu/qemu_command.c +++ w/src/qemu/qemu_command.c @@ -6152,8 +6152,15 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArgList(cmd, -initrd, def-os.initrd, NULL); if (def-os.cmdline) virCommandAddArgList(cmd, -append, def-os.cmdline, NULL); -if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB) def-os.dtb) -virCommandAddArgList(cmd, -dtb, def-os.dtb, NULL); +if (def-os.dtb) { +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB)) { +virCommandAddArgList(cmd, -dtb, def-os.dtb, NULL); +} else { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(dtb is not supported with this QEMU binary)); +goto error; +} +} } else { virCommandAddArgList(cmd, -bootloader, def-os.bootloader, NULL); } diff --git i/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args w/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args index a66ac51..93e8f9c 100644 --- i/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args +++ w/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args @@ -1 +1,6 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-system-ppc -S -M ppce500v2 -m 256 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -kernel /media/ram/uImage -initrd /media/ram/ramdisk -append 'root=/dev/ram rw console=ttyS0,115200' -dtb /media/ram/test.dtb -usb -net none -serial pty -parallel none +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \ +/usr/bin/qemu-system-ppc -S -M ppce500v2 -m 256 -smp 1 -nographic \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-kernel /media/ram/uImage -initrd /media/ram/ramdisk \ +-append 'root=/dev/ram rw console=ttyS0,115200' -dtb /media/ram/test.dtb \ +-usb -net none -serial pty -parallel none -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 1/4] rename qemuGetNumadAdvice to virNumaGetAutoPlacementAdvice
On 03/18/2013 03:04 AM, Gao feng wrote: qemuGetNumadAdvice will be used by LXC driver,rename space after comma it to virNumaGetAutoPlacementAdvice and move it to virnuma.c Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- po/POTFILES.in | 1 + src/Makefile.am | 1 + src/libvirt_private.syms | 3 +++ src/qemu/qemu_process.c | 34 +++ src/util/virnuma.c | 61 src/util/virnuma.h | 28 ++ 6 files changed, 97 insertions(+), 31 deletions(-) create mode 100644 src/util/virnuma.c create mode 100644 src/util/virnuma.h Wow, I've never seen 'git am' get so confused: ... A qemu/qemu_process.c Falling back to patching base and 3-way merge... CONFLICT (rename/add): Rename Makefile.am-src/Makefile.am in rename qemuGetNumadAdvice to virNumaGetAutoPlacementAdvice. src/Makefile.am added in HEAD Adding as src/Makefile.am~HEAD instead Auto-merging src/qemu/qemu_process.c Auto-merging src/libvirt_private.syms Auto-merging src/Makefile.am CONFLICT (content): Merge conflict in src/Makefile.am ... Thankfully, I was able to straighten it out, and have pushed this patch. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] libvirtd segfault
Op maandag 18 maart 2013 18:19:51 schreef Jiri Denemark: On Thu, Mar 14, 2013 at 20:01:16 +0100, AL13N wrote: Op maandag 11 maart 2013 12:59:08 schreef Eric Blake: On 03/10/2013 09:25 AM, AL13N wrote: regarding http://www.redhat.com/archives/libvir-list/2012-December/msg01365.html and https://www.redhat.com/archives/libvir-list/2012-December/msg00935.htm l There have been several fixes to shutdown since December; can you reproduce the problem with libvirt 1.0.3? this is the journalctl output https://gist.github.com/5164169 Thanks, but debug logs without a backtrace are not usually very helpful in case of a segfault. Could you setup your system to store libvirtd's core once it crashes, make sure you have all required debuginfo symbols installed, and use gdb to get the backtrace using ``thread apply all backtrace'' command? here it is... Thread 12 (Thread 0x7fdeedbac700 (LWP 20534)): #0 0x7fdef5b625c4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 #1 0x7fdef5df4766 in virCondWait (c=c@entry=0x1146428, m=m@entry=0x1146368) at util/virthreadpthread.c:117 #2 0x7fdef5df4bcb in virThreadPoolWorker (opaque=opaque@entry=0x1123ac0) at util/virthreadpool.c:103 #3 0x7fdef5df4599 in virThreadHelper (data=optimized out) at util/virthreadpthread.c:161 #4 0x7fdef5b5ed18 in start_thread () from /lib64/libpthread.so.0 #5 0x7fdef568987d in clone () from /lib64/libc.so.6 #6 0x in ?? () Thread 11 (Thread 0x7fdeed3ab700 (LWP 20535)): #0 0x7fdef5b625c4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 #1 0x7fdef5df4766 in virCondWait (c=c@entry=0x1146428, m=m@entry=0x1146368) at util/virthreadpthread.c:117 #2 0x7fdef5df4bcb in virThreadPoolWorker (opaque=opaque@entry=0x1123c40) at util/virthreadpool.c:103 #3 0x7fdef5df4599 in virThreadHelper (data=optimized out) at util/virthreadpthread.c:161 #4 0x7fdef5b5ed18 in start_thread () from /lib64/libpthread.so.0 #5 0x7fdef568987d in clone () from /lib64/libc.so.6 #6 0x in ?? () Thread 10 (Thread 0x7fdef0bb2700 (LWP 20528)): #0 0x7fdef5b64eaa in __lll_unlock_wake () from /lib64/libpthread.so.0 #1 0x7fdef5b61b09 in _L_unlock_572 () from /lib64/libpthread.so.0 #2 0x7fdef5b61aa1 in __pthread_mutex_unlock_usercnt () from /lib64/libpthread.so.0 #3 0x7fdee9a734b3 in libxl__ctx_unlock (ctx=optimized out) at libxl_internal.h:2659 #4 libxl__ao_inprogress (ao=ao@entry=0x7fdedc000c60, file=file@entry=0x7fdee9a7c460 libxl.c, line=line@entry=1276, func=func@entry=0x7fdee9a7e310 __func__.15903 libxl_domain_destroy) at libxl_event.c:1627 #5 0x7fdee9a4d458 in libxl_domain_destroy (ctx=0x7fdee40fe240, domid=38, ao_how=ao_how@entry=0x0) at libxl.c:1276 #6 0x7fdee9ca5d22 in libxlVmReap (driver=0x7fdee40c98b0, vm=0x7fdee40f30f0, reason=VIR_DOMAIN_SHUTOFF_DESTROYED) at libxl/libxl_driver.c:659 #7 0x7fdee9ca5e49 in libxlDomainDestroyFlags (dom=0x7fdedc000c00, flags=optimized out) at libxl/libxl_driver.c:1799 #8 0x7fdef5e68417 in virDomainDestroy (domain=domain@entry=0x7fdedc000c00) at libvirt.c:2224 #9 0x0042b9a6 in remoteDispatchDomainDestroy (args=optimized out, rerr=0x7fdef0bb1ca0, client=0x1156a40, server=optimized out, msg=optimized out) at remote_dispatch.h:1277 #10 remoteDispatchDomainDestroyHelper (server=optimized out, client=0x1156a40, msg=optimized out, rerr=0x7fdef0bb1ca0, args=optimized out, ret=optimized out) at remote_dispatch.h:1255 #11 0x7fdef5ecd1ca in virNetServerProgramDispatchCall (msg=0x1156e10, client=0x1156a40, server=0x1146220, prog=0x1153560) at rpc/virnetserverprogram.c:432 #12 virNetServerProgramDispatch (prog=0x1153560, server=server@entry=0x1146220, client=0x1156a40, msg=0x1156e10) at rpc/virnetserverprogram.c:305 #13 0x7fdef5ec82e8 in virNetServerProcessMsg (msg=optimized out, prog=optimized out, client=optimized out, srv=0x1146220) at rpc/virnetserver.c:162 #14 virNetServerHandleJob (jobOpaque=optimized out, opaque=0x1146220) at rpc/virnetserver.c:183 #15 0x7fdef5df4b0e in virThreadPoolWorker (opaque=opaque@entry=0x1123ac0) at util/virthreadpool.c:144 #16 0x7fdef5df4599 in virThreadHelper (data=optimized out) at util/virthreadpthread.c:161 #17 0x7fdef5b5ed18 in start_thread () from /lib64/libpthread.so.0 #18 0x7fdef568987d in clone () from /lib64/libc.so.6 #19 0x in ?? () Thread 9 (Thread 0x7fdeee3ad700 (LWP 20533)): #0 0x7fdef5b64e0c in __lll_lock_wait () from /lib64/libpthread.so.0 #1 0x7fdef5b60cb4 in _L_lock_850 () from /lib64/libpthread.so.0 #2 0x7fdef5b60bb7 in pthread_mutex_lock () from /lib64/libpthread.so.0 #3 0x7fdef5df46f5 in virMutexLock (m=optimized out) at util/virthreadpthread.c:85 #4 0x7fdee9c9fac5 in libxlDriverLock (driver=optimized out) at libxl/libxl_driver.c:131 #5 0x7fdee9ca301a in libxlNumDomains
Re: [libvirt] [test-API][PATCH] The patch covers all nwfilter api provided by libvirt.py. It includes define/undefine/list nwfilters and check them via checking ebtables rule. The following new files
On 03/18/2013 05:53 PM, Osier Yang wrote: On 2013年03月18日 14:54, hongming wrote: Can you shorten the patch subject? And add the sentences in the commit log instead? Sorry , Please ignore the patch . I made a mistake when generate patch . I send another patch with subject - Add nwfilter test cases and conf --- cases/nwfilter.conf | 59 + repos/nwfilter/nwfilter_check.py| 120 +++ repos/nwfilter/nwfilter_define.py | 54 repos/nwfilter/nwfilter_list.py | 76 ++ repos/nwfilter/nwfilter_undefine.py | 43 + repos/nwfilter/xmls/nwfilter.xml|3 + 6 files changed, 355 insertions(+), 0 deletions(-) create mode 100644 cases/nwfilter.conf create mode 100644 repos/nwfilter/__init__.py create mode 100644 repos/nwfilter/nwfilter_check.py create mode 100644 repos/nwfilter/nwfilter_define.py create mode 100644 repos/nwfilter/nwfilter_list.py create mode 100644 repos/nwfilter/nwfilter_undefine.py create mode 100644 repos/nwfilter/xmls/nwfilter.xml diff --git a/cases/nwfilter.conf b/cases/nwfilter.conf new file mode 100644 index 000..b394ee5 --- /dev/null +++ b/cases/nwfilter.conf @@ -0,0 +1,59 @@ +domain:install_linux_cdrom +guestname +$defaultname +guestos +$defaultos +guestarch +$defaultarch +vcpu +$defaultvcpu +memory +$defaultmem +hddriver +$defaulthd +nicdriver +$defaultnic +imageformat +qcow2 +macaddr +54:52:00:4a:16:30 + +nwfilter:nwfilter_list + +# chain -- ipv4, ipv6, arp .etc +# action -- mandatory; drop, accept, return +# direction -- mandatory; must either be in, out or inout +nwfilter:nwfilter_define +nwfiltername +disallow-arp +chain +arp +action +drop +direction +inout + +nwfilter:nwfilter_list + +nwfilter:nwfilter_check +nwfiltername +disallow-arp +guestname +$defaultname + +nwfilter:nwfilter_define +nwfiltername +disallow-ipv6 +chain +ipv6 +action +drop +direction +in + +nwfilter:nwfilter_undefine +nwfiltername +disallow-ipv6 + +nwfilter:nwfilter_list + diff --git a/repos/nwfilter/__init__.py b/repos/nwfilter/__init__.py new file mode 100644 index 000..e69de29 diff --git a/repos/nwfilter/nwfilter_check.py b/repos/nwfilter/nwfilter_check.py new file mode 100644 index 000..b2c7ece --- /dev/null +++ b/repos/nwfilter/nwfilter_check.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python +import time +import xml.dom.minidom + +from libvirt import libvirtError +from utils import utils +from xml.dom import minidom + +from src import sharedmod + +required_params = ('nwfiltername','guestname',) +optional_params = {} + +EBTABLES = ebtables -t nat -L + +def get_ebtables(): + Get the output of ebtables +(status, output) = utils.exec_cmd(EBTABLES,shell=True) +logger.info(Execute command: + EBTABLES) +ebtables_list = [] + +if status: +logger.error(Executing + EBTABLES + failed) +logger.error(output) +return False +else: +for i in range(len(output)): +ebtables_list.append(output[i]) +logger.info(Get the output of ebtables list: %s \ +% ebtables_list) + +return ebtables_list + +def check_ebtables(*args): + Check the ebtables +(nwfiltername,conn)= args +ebtables_list = get_ebtables() + +#Get the filter' attribute value +nwfilter_xml = conn.nwfilterLookupByName(nwfiltername).XMLDesc(0) +nwfilter_parsedxml = minidom.parseString(nwfilter_xml) +chain = nwfilter_parsedxml.getElementsByTagName(filter)[0].\ +getAttribute(chain) +rule = nwfilter_parsedxml.getElementsByTagName(rule)[0] +action = rule.getAttribute(action).upper() +direction = rule.getAttribute(direction) +logger.info(The nwfilter chain:%s ,action:%s ,direction:%s %\ +(chain,action,direction) ) +in_vnet_chain = I-vnet0- + chain +out_vnet_chain = O-vnet0- + chain + +if cmp(direction,inout) == 0 : +if len(ebtables_list) == 21 and in_vnet_chain in ebtables_list[-5]\ +and out_vnet_chain in ebtables_list[-2] \ +and action in ebtables_list[-1] \ +and action in ebtables_list[-4]: +return True +else: +return False +elif cmp(direction,in) == 0: +if len(ebtables_list) == 14 and out_vnet_chain in ebtables_list[-2]\ +and action in ebtables_list[-1]: +return True +else: +return False + +elif cmp(direction,out) == 0: +if len(ebtables_list) == 14 and in_vnet_chain in ebtables_list[-2] \ +and action in ebtables_list[-1]: +return True +else: +return False + +def nwfilter_check(params): +Check the nwfilter via checking ebtales +
Re: [libvirt] [PATCH v3 RESEND 3/4] NUMA: cleanup for numa related codes
于 2013/03/19/ 17:59, Daniel P. Berrange wrote: On Tue, Mar 19, 2013 at 09:59:37AM +0800, Gao feng wrote: Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/conf/domain_conf.c | 17 ++- src/conf/domain_conf.h | 17 +-- src/libvirt_private.syms | 5 +- src/lxc/lxc_controller.c | 114 +- src/qemu/qemu_cgroup.c | 4 +- src/qemu/qemu_process.c | 121 + src/util/virnuma.c | 126 +++ src/util/virnuma.h | 30 +++ 8 files changed, 168 insertions(+), 266 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 96f11ba..98c4745 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -47,6 +47,7 @@ # include device_conf.h # include virbitmap.h # include virstoragefile.h +# include virnuma.h /* forward declarations of all device types, required by * virDomainDeviceDef @@ -1700,18 +1701,6 @@ virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def, int nvcpupin, int vcpu); -typedef struct _virDomainNumatuneDef virDomainNumatuneDef; -typedef virDomainNumatuneDef *virDomainNumatuneDefPtr; -struct _virDomainNumatuneDef { -struct { -virBitmapPtr nodemask; -int mode; -int placement_mode; /* enum virDomainNumatuneMemPlacementMode */ -} memory; - -/* Future NUMA tuning related stuff should go here. */ -}; - typedef struct _virBlkioDeviceWeight virBlkioDeviceWeight; typedef virBlkioDeviceWeight *virBlkioDeviceWeightPtr; struct _virBlkioDeviceWeight { @@ -1801,7 +1790,7 @@ struct _virDomainDef { virDomainVcpuPinDefPtr emulatorpin; } cputune; -virDomainNumatuneDef numatune; +virNumatuneDef numatune; /* These 3 are based on virDomainLifeCycleAction enum flags */ int onReboot; @@ -2396,8 +2385,6 @@ VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression) VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode) VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste) VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode) -VIR_ENUM_DECL(virDomainNumatuneMemMode) -VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode) VIR_ENUM_DECL(virDomainHyperv) VIR_ENUM_DECL(virDomainRNGModel) VIR_ENUM_DECL(virDomainRNGBackend) diff --git a/src/util/virnuma.h b/src/util/virnuma.h index d3d7d3e..ef201b9 100644 --- a/src/util/virnuma.h +++ b/src/util/virnuma.h @@ -22,7 +22,37 @@ #ifndef __VIR_NUMA_H__ # define __VIR_NUMA_H__ +# include internal.h +# include virbitmap.h +# include virutil.h + +enum virNumatuneMemPlacementMode { +VIR_NUMATUNE_MEM_PLACEMENT_MODE_DEFAULT = 0, +VIR_NUMATUNE_MEM_PLACEMENT_MODE_STATIC, +VIR_NUMATUNE_MEM_PLACEMENT_MODE_AUTO, + +VIR_NUMATUNE_MEM_PLACEMENT_MODE_LAST +}; This enum is previously defined in domain_conf.h, but you've not removed it from there, so now we have 2 enums for the same thing. Oops,I forgot to remove it. Also you've ignore my request to use virNumaTune as the capatilization and VIR_NUMA_TUNE for enums Get it,if I use virNumatune as the capatilization,I need to change virnuma.[c|h] to virnumatune.[c|h]? Thanks for your comments. + +VIR_ENUM_DECL(virNumatuneMemPlacementMode) + +VIR_ENUM_DECL(virDomainNumatuneMemMode) + +typedef struct _virNumatuneDef virNumatuneDef; +typedef virNumatuneDef *virNumatuneDefPtr; +struct _virNumatuneDef { +struct { +virBitmapPtr nodemask; +int mode; +int placement_mode; /* enum virNumatuneMemPlacementMode */ +} memory; + +/* Future NUMA tuning related stuff should go here. */ +}; Again virNumaTune should be the name prefix NACK, Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 1/4] rename qemuGetNumadAdvice to virNumaGetAutoPlacementAdvice
于 2013/03/20 05:56, Eric Blake wrote: On 03/18/2013 03:04 AM, Gao feng wrote: qemuGetNumadAdvice will be used by LXC driver,rename space after comma it to virNumaGetAutoPlacementAdvice and move it to virnuma.c Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- po/POTFILES.in | 1 + src/Makefile.am | 1 + src/libvirt_private.syms | 3 +++ src/qemu/qemu_process.c | 34 +++ src/util/virnuma.c | 61 src/util/virnuma.h | 28 ++ 6 files changed, 97 insertions(+), 31 deletions(-) create mode 100644 src/util/virnuma.c create mode 100644 src/util/virnuma.h Wow, I've never seen 'git am' get so confused: ... A qemu/qemu_process.c Falling back to patching base and 3-way merge... CONFLICT (rename/add): Rename Makefile.am-src/Makefile.am in rename qemuGetNumadAdvice to virNumaGetAutoPlacementAdvice. src/Makefile.am added in HEAD Adding as src/Makefile.am~HEAD instead Auto-merging src/qemu/qemu_process.c Auto-merging src/libvirt_private.syms Auto-merging src/Makefile.am CONFLICT (content): Merge conflict in src/Makefile.am ... Thankfully, I was able to straighten it out, and have pushed this patch. Thanks for your work, I will rebase the other three patches and resend them. Thanks! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 2/3] qemu: add dtb option supprt
Hi Eric, You're so kind to help squash. Thank you very much. Exactly there's one more thing need fix is that 'ppce500v2' should be changed as 'ppce500' to align with qemu-1.4.0. What should I do next step? Should I post a new revision of patchset? Best Regards, Olivia -Original Message- From: Eric Blake [mailto:ebl...@redhat.com] Sent: Wednesday, March 20, 2013 5:24 AM To: Yin Olivia-R63875 Cc: libvir-list@redhat.com Subject: Re: [libvirt] [PATCH v5 2/3] qemu: add dtb option supprt On 03/13/2013 10:49 PM, Olivia Yin wrote: The dtb option sets the filename for the device tree. If without this option support, -dtb file will be converted into qemu:commandline in domain XML file. For example, '-dtb /media/ram/test.dtb' will be converted into qemu:commandline qemu:arg value='-dtb'/ qemu:arg value='/media/ram/test.dtb'/ /qemu:commandline +++ b/src/qemu/qemu_command.c @@ -5984,6 +5984,8 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArgList(cmd, -initrd, def-os.initrd, NULL); if (def-os.cmdline) virCommandAddArgList(cmd, -append, def-os.cmdline, NULL); +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB) def-os.dtb) +virCommandAddArgList(cmd, -dtb, def-os.dtb, NULL); This silently ignores def-os.dtb if set but qemu is too old. Instead, we should error out on the unsupported combination. +++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test +/usr/bin/qemu-system-ppc -S -M ppce500v2 -m 256 -smp 1 -nographic +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c +-kernel /media/ram/uImage -initrd /media/ram/ramdisk -append +'root=/dev/ram rw console=ttyS0,115200' -dtb /media/ram/test.dtb -usb +-net none -serial pty -parallel none Sheesh, this line is long. Backslash-newline is your friend. In addition to what I'm squashing after Dan's comments, I'm adding this: diff --git i/src/qemu/qemu_command.c w/src/qemu/qemu_command.c index 0b56726..8626b62 100644 --- i/src/qemu/qemu_command.c +++ w/src/qemu/qemu_command.c @@ -6152,8 +6152,15 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArgList(cmd, -initrd, def-os.initrd, NULL); if (def-os.cmdline) virCommandAddArgList(cmd, -append, def-os.cmdline, NULL); -if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB) def-os.dtb) -virCommandAddArgList(cmd, -dtb, def-os.dtb, NULL); +if (def-os.dtb) { +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB)) { +virCommandAddArgList(cmd, -dtb, def-os.dtb, NULL); +} else { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(dtb is not supported with this QEMU binary)); +goto error; +} +} } else { virCommandAddArgList(cmd, -bootloader, def-os.bootloader, NULL); } diff --git i/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args w/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args index a66ac51..93e8f9c 100644 --- i/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args +++ w/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args @@ -1 +1,6 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu- system-ppc -S -M ppce500v2 -m 256 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -kernel /media/ram/uImage -initrd /media/ram/ramdisk -append 'root=/dev/ram rw console=ttyS0,115200' -dtb /media/ram/test.dtb -usb -net none -serial pty - parallel none +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \ +/usr/bin/qemu-system-ppc -S -M ppce500v2 -m 256 -smp 1 -nographic \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-kernel /media/ram/uImage -initrd /media/ram/ramdisk \ -append +'root=/dev/ram rw console=ttyS0,115200' -dtb /media/ram/test.dtb \ -usb +-net none -serial pty -parallel none -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 2/3] qemu: add dtb option supprt
On 03/19/2013 07:41 PM, Yin Olivia-R63875 wrote: Hi Eric, You're so kind to help squash. Thank you very much. No problem. You can return the favor by helping review other outstanding patches. Exactly there's one more thing need fix is that 'ppce500v2' should be changed as 'ppce500' to align with qemu-1.4.0. What should I do next step? Should I post a new revision of patchset? At this point, your original patches are already part of libvirt.git, so you will need to post the fix as a new patch. Starting a new thread will give it better visibility. Also, we tend to avoid top-posting on technical lists. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 RESEND 3/4] NUMA: cleanup for numa related codes
On 03/19/2013 07:26 PM, Gao feng wrote: Also you've ignore my request to use virNumaTune as the capatilization and VIR_NUMA_TUNE for enums Get it,if I use virNumatune as the capatilization,I need to change virnuma.[c|h] to virnumatune.[c|h]? No. We want 'virNuma' to be the set of functions related to numa operations; among those operations are the set of functions related to tuning numa setup, ergo virNumaTune. A lot of our functions are named in the same manner of prefixObjectVerb, such as virObjectDispose. There is no word 'numatune', and no need to rename virnuma.[ch] to a longer name. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 2/4] LXC: allow uses advisory nodeset from querying numad
On 03/18/2013 08:30 AM, Daniel P. Berrange wrote: On Mon, Mar 18, 2013 at 05:04:02PM +0800, Gao feng wrote: Allow lxc using the advisory nodeset from querying numad, this means if user doesn't specify the numa nodes that the lxc domain should assign to, libvirt will automatically bind the lxc domain to the advisory nodeset which queried from numad. Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/lxc/lxc_controller.c | 77 ++-- 1 file changed, 68 insertions(+), 9 deletions(-) ACK This one is pushed as well. I'll wait for your v4 rebase of 3 and 4. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: add PCI-multibus support for ppc
Hi Daniel, PPC also supports PCI multibus. Could you please help review this patch? Best Regards, Olivia -Original Message- From: Yin Olivia-R63875 Sent: Wednesday, March 13, 2013 12:44 PM To: libvir-list@redhat.com Cc: Yin Olivia-R63875 Subject: [PATCH] qemu: add PCI-multibus support for ppc Signed-off-by: Olivia Yin hong-hua@freescale.com --- src/qemu/qemu_capabilities.c | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7bc1ebc..7d7791d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2209,6 +2209,11 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid) virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI); } +/* ppc support PCI-multibus */ +if (qemuCaps-arch == VIR_ARCH_PPC) { +virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS); +} + /* virQEMUCapsExtractDeviceStr will only set additional caps if qemu * understands the 0.13.0+ notion of -device driver,. */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) @@ -2450,6 +2455,11 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI); } +/* ppc support PCI-multibus */ +if (qemuCaps-arch == VIR_ARCH_PPC) { +virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS); +} + if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) 0) goto cleanup; if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) 0) -- 1.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] replace ppce500v2 with ppce500
--- docs/schemas/domaincommon.rng| 2 +- tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml | 2 +- tests/testutilsqemu.c| 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 90647df..5a871d6 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -367,7 +367,7 @@ valueg3beige/value valuemac99/value valueprep/value -valueppce500v2/value +valueppce500/value /choice /attribute /optional diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args index 93e8f9c..1ffd8be 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \ -/usr/bin/qemu-system-ppc -S -M ppce500v2 -m 256 -smp 1 -nographic \ +/usr/bin/qemu-system-ppc -S -M ppce500 -m 256 -smp 1 -nographic \ -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ -kernel /media/ram/uImage -initrd /media/ram/ramdisk \ -append 'root=/dev/ram rw console=ttyS0,115200' -dtb /media/ram/test.dtb \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml index 3674621..04f0eb6 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml @@ -5,7 +5,7 @@ currentMemory unit='KiB'262144/currentMemory vcpu placement='static'1/vcpu os -type arch='ppc' machine='ppce500v2'hvm/type +type arch='ppc' machine='ppce500'hvm/type kernel/media/ram/uImage/kernel initrd/media/ram/ramdisk/initrd cmdlineroot=/dev/ram rw console=ttyS0,115200/cmdline diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index db15ee6..35d6158 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -97,7 +97,7 @@ static int testQemuAddPPCGuest(virCapsPtr caps) static const char *machine[] = { g3beige, mac99, prep, - ppce500v2 }; + ppce500 }; virCapsGuestMachinePtr *machines = NULL; virCapsGuestPtr guest; -- 1.8.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] fix TLS error with virNetServerClientCreateIdentity
--- src/rpc/virnetserverclient.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index d407f5e..58fb0b4 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -687,6 +687,7 @@ virNetServerClientCreateIdentity(virNetServerClientPtr client) } #endif +#if WITH_GNUTLS if (client-tls) { const char *identity = virNetTLSSessionGetX509DName(client-tls); if (identity @@ -695,6 +696,7 @@ virNetServerClientCreateIdentity(virNetServerClientPtr client) goto cleanup; } } +#endif if (client-sock virNetSocketGetSecurityContext(client-sock, seccontext) 0) -- 1.8.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix TLS error with virNetServerClientCreateIdentity
On 03/19/2013 08:13 PM, Olivia Yin wrote: --- src/rpc/virnetserverclient.c | 2 ++ 1 file changed, 2 insertions(+) ACK and pushed. I tweaked the commit message to call out the culprit commit that introduced the problem (d5e83ad). -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] replace ppce500v2 with ppce500
On 03/19/2013 08:13 PM, Olivia Yin wrote: --- docs/schemas/domaincommon.rng| 2 +- Your commit message is sparse. This is a good place to explain WHY a maintainer should apply your patch. On my Fedora 18 box, I see: $ qemu-ppc64 -cpu help | grep e500 PowerPC e500_v10 PVR 80200010 PowerPC e500_v20 PVR 80200020 PowerPC e500v1 PVR 80200020 PowerPC e500v2_v10 PVR 80210010 PowerPC e500v2_v20 PVR 80210020 PowerPC e500v2_v21 PVR 80210021 PowerPC e500v2_v22 PVR 80210022 PowerPC e500v2 PVR 80210022 PowerPC e500 PVR 80210022 PowerPC e500v2_v30 PVR 80210030 PowerPC e500mc PVR 80230020 Doesn't that mean that both 'ppce500' AND 'ppce500v2' (and several others) should all be valid machine names? If anything, we should either relax the RNG grammar to allow freeform names (since the code wasn't really checking), or we should enhance the grammar and C code to call out the entire list of values that qemu supports. With as many ppc variants as qemu seems to support, trying to maintain a list seems like duplicated effort where we will constantly be behind. Therefore, I think the best action is to do a mix: relax the grammar to allow any string (the way we already do for x86), but then do a validation in the C code that the string chosen by the user is supported by qemu (instead of the current approach of not caring about the string). I'm not yet convinced that this patch should be applied. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] about Application_Development_Guide.pdf
Daniel,thanks for replying ! i want to be involved with libvirt program, if I delicate myself to writing more content for the docs,what could i do ? I'm familiar with java and python,by the way ,i'm chinese,so there may be some risks that the docs i write can not be understanded by others. Best wishes! Sheldon. At 2013-03-19 20:28:34,Daniel P. Berrange berra...@redhat.com wrote: On Tue, Mar 19, 2013 at 02:17:43PM +0800, huyp1024 wrote: HI,buddy. I'm sheldon. I'm trying to develop virtual machine lifecycle management software using libvirt. I found the development guide is very useful,it helps a lot. But this book I download from offical website is a draft,there are a lot of funcitons which are not claimed. I appreciate very much that you give me some document that developers are being in reference to . We'd love this doc to be more complete, but we're lacking people with sufficient time / dedication to write for content for the docs. So I'm afraid it'll probably be an incomplete, draft for a while yet :-( If anyone out there is motivated to write more docs, we keep the source in GIT http://libvirt.org/git/?p=libvirt-appdev-guide.git;a=summary It is using DocBook XML format, to generate PDF + HTML output. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH RESEND 2/2] LXC: add cpuset cgroup support for lxc
This patch adds cpuset cgroup support for LXC. Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/lxc/lxc_cgroup.c | 57 +++- src/lxc/lxc_cgroup.h | 4 +++- src/lxc/lxc_controller.c | 2 +- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index fa47229..df468da 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -68,6 +68,57 @@ cleanup: } +static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def, + virCgroupPtr cgroup, + virBitmapPtr nodemask) +{ +int rc = 0; +char *mask = NULL; + +if (def-placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO +def-cpumask) { +mask = virBitmapFormat(def-cpumask); +if (!mask) { +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(failed to convert cpumask)); +return -1; +} + +rc = virCgroupSetCpusetCpus(cgroup, mask); +if (rc 0) { +virReportSystemError(-rc, %s, + _(Unable to set cpuset.cpus)); +goto cleanup; +} +} + +if ((def-numatune.memory.nodemask || + (def-numatune.memory.placement_mode == + VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) + def-numatune.memory.mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) { +if (def-numatune.memory.placement_mode == +VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO) +mask = virBitmapFormat(nodemask); +else +mask = virBitmapFormat(def-numatune.memory.nodemask); + +if (!mask) { +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(failed to convert memory nodemask)); +return -1; +} + +rc = virCgroupSetCpusetMems(cgroup, mask); +if (rc 0) +virReportSystemError(-rc, %s, _(Unable to set cpuset.mems)); +} + +cleanup: +VIR_FREE(mask); +return rc; +} + + static int virLXCCgroupSetupBlkioTune(virDomainDefPtr def, virCgroupPtr cgroup) { @@ -516,13 +567,17 @@ cleanup: int virLXCCgroupSetup(virDomainDefPtr def, - virCgroupPtr cgroup) + virCgroupPtr cgroup, + virBitmapPtr nodemask) { int ret = -1; if (virLXCCgroupSetupCpuTune(def, cgroup) 0) goto cleanup; +if (virLXCCgroupSetupCpusetTune(def, cgroup, nodemask) 0) +goto cleanup; + if (virLXCCgroupSetupBlkioTune(def, cgroup) 0) goto cleanup; diff --git a/src/lxc/lxc_cgroup.h b/src/lxc/lxc_cgroup.h index 18f54e6..942e0fc 100644 --- a/src/lxc/lxc_cgroup.h +++ b/src/lxc/lxc_cgroup.h @@ -28,7 +28,9 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def); int virLXCCgroupSetup(virDomainDefPtr def, - virCgroupPtr cgroup); + virCgroupPtr cgroup, + virBitmapPtr nodemask); + int virLXCCgroupGetMeminfo(virLXCMeminfoPtr meminfo); int diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index f19f8c1..37e3ce9 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -569,7 +569,7 @@ static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl, if (virLXCControllerSetupCpuAffinity(ctrl) 0) goto cleanup; -if (virLXCCgroupSetup(ctrl-def, cgroup) 0) +if (virLXCCgroupSetup(ctrl-def, cgroup, nodemask) 0) goto cleanup; ret = 0; -- 1.7.11.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH RESEND 1/2] NUMA: cleanup for numa related codes
Intend to reduce the redundant code,use virNumaSetupMemoryPolicy to replace virLXCControllerSetupNUMAPolicy and qemuProcessInitNumaMemoryPolicy. This patch also moves the numa related codes to the file virnuma.c and virnuma.h Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/conf/domain_conf.c | 31 src/conf/domain_conf.h | 25 +- src/libvirt_private.syms | 9 ++-- src/lxc/lxc_controller.c | 116 +-- src/qemu/qemu_cgroup.c | 4 +- src/qemu/qemu_driver.c | 6 +-- src/qemu/qemu_process.c | 123 + src/util/virnuma.c | 126 +++ src/util/virnuma.h | 30 +++ 9 files changed, 182 insertions(+), 288 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a1cfc76..fa70329 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -690,11 +690,6 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST, paravirt, smpsafe); -VIR_ENUM_IMPL(virDomainNumatuneMemMode, VIR_DOMAIN_NUMATUNE_MEM_LAST, - strict, - preferred, - interleave); - VIR_ENUM_IMPL(virDomainStartupPolicy, VIR_DOMAIN_STARTUP_POLICY_LAST, default, mandatory, @@ -709,12 +704,6 @@ VIR_ENUM_IMPL(virDomainDiskTray, VIR_DOMAIN_DISK_TRAY_LAST, closed, open); -VIR_ENUM_IMPL(virDomainNumatuneMemPlacementMode, - VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_LAST, - default, - static, - auto); - VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, virtio); @@ -9852,7 +9841,7 @@ virDomainDefParseXML(virCapsPtr caps, int placement_mode = 0; if (placement) { if ((placement_mode = - virDomainNumatuneMemPlacementModeTypeFromString(placement)) 0) { + virNumaTuneMemPlacementModeTypeFromString(placement)) 0) { virReportError(VIR_ERR_XML_ERROR, _(Unsupported memory placement mode '%s'), placement); @@ -9862,18 +9851,18 @@ virDomainDefParseXML(virCapsPtr caps, VIR_FREE(placement); } else if (def-numatune.memory.nodemask) { /* Defaults to static if nodeset is specified. */ -placement_mode = VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC; +placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC; } else { /* Defaults to placement of vcpu if nodeset is * not specified. */ if (def-placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC) -placement_mode = VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC; +placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC; else -placement_mode = VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO; +placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO; } -if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC +if (placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC !def-numatune.memory.nodemask) { virReportError(VIR_ERR_XML_ERROR, %s, _(nodeset for NUMA memory tuning must be set @@ -9882,13 +9871,13 @@ virDomainDefParseXML(virCapsPtr caps, } /* Ignore 'nodeset' if 'placement' is 'auto' finally */ -if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO) +if (placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO) virBitmapFree(def-numatune.memory.nodemask); /* Copy 'placement' of numatune to vcpu if its 'placement' * is not specified and 'placement' of numatune is specified. */ -if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO +if (placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO !def-cpumask) def-placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO; @@ -9907,7 +9896,7 @@ virDomainDefParseXML(virCapsPtr caps, * and 'placement' of vcpu is 'auto'. */ if (def-placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) { -def-numatune.memory.placement_mode =