From 03a37ddd875a4a7f979ab26a8c3e29e363697b8fc77a928b58087b53b99d1de0 Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Thu, 16 Jan 2014 20:18:13 +0000 Subject: [PATCH] - Fix the spec file to build for old distros The xm/xend toolstack will continue to be contained in xen-tools for older openSUSE and sles distros but it will be contained in xend-tools for os13.x - fate#316071: add discard support for file backed storage (qdisk) to qemu-upstream, enabled unconditionally OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=290 --- qemu-xen-upstream-blkif-discard.patch | 145 ++++++++++++++++++++++++++ xen.changes | 14 +++ xen.spec | 124 ++++++++++++++++++---- 3 files changed, 263 insertions(+), 20 deletions(-) create mode 100644 qemu-xen-upstream-blkif-discard.patch diff --git a/qemu-xen-upstream-blkif-discard.patch b/qemu-xen-upstream-blkif-discard.patch new file mode 100644 index 0000000..172493a --- /dev/null +++ b/qemu-xen-upstream-blkif-discard.patch @@ -0,0 +1,145 @@ +References: FATE#316071 +Subject: [RFC] qemu-upstream: add discard support for xen_disk + +Implement discard support for xen_disk. It makes use of the existing +discard code in qemu. + +The discard support is enabled unconditionally. But it would be worth to +have a knob to disable it in case the backing file was intentionally +created non-sparse to avoid fragmentation. +How could this be knob be passed from domU.cfg:disk=[] to the actual +qemu process? Perhaps introduce an option discard=on|off|ignore|unmap. + +Signed-off-by: Olaf Hering + +--- + tools/qemu-xen-dir-remote/hw/block/xen_blkif.h | 12 ++++++++ + tools/qemu-xen-dir-remote/hw/block/xen_disk.c | 36 +++++++++++++++++++++++++ + 2 files changed, 48 insertions(+) + +Index: xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_blkif.h +=================================================================== +--- xen-4.4.0-testing.orig/tools/qemu-xen-dir-remote/hw/block/xen_blkif.h ++++ xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_blkif.h +@@ -79,6 +79,12 @@ static inline void blkif_get_x86_32_req( + dst->handle = src->handle; + dst->id = src->id; + dst->sector_number = src->sector_number; ++ if (src->operation == BLKIF_OP_DISCARD) { ++ struct blkif_request_discard *s = (void *)src; ++ struct blkif_request_discard *d = (void *)dst; ++ d->nr_sectors = s->nr_sectors; ++ return; ++ } + if (n > src->nr_segments) + n = src->nr_segments; + for (i = 0; i < n; i++) +@@ -94,6 +100,12 @@ static inline void blkif_get_x86_64_req( + dst->handle = src->handle; + dst->id = src->id; + dst->sector_number = src->sector_number; ++ if (src->operation == BLKIF_OP_DISCARD) { ++ struct blkif_request_discard *s = (void *)src; ++ struct blkif_request_discard *d = (void *)dst; ++ d->nr_sectors = s->nr_sectors; ++ return; ++ } + if (n > src->nr_segments) + n = src->nr_segments; + for (i = 0; i < n; i++) +Index: xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_disk.c +=================================================================== +--- xen-4.4.0-testing.orig/tools/qemu-xen-dir-remote/hw/block/xen_disk.c ++++ xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_disk.c +@@ -68,6 +68,8 @@ struct ioreq { + int presync; + int postsync; + uint8_t mapped; ++ int64_t sector_num; ++ int nb_sectors; + + /* grant mapping */ + uint32_t domids[BLKIF_MAX_SEGMENTS_PER_REQUEST]; +@@ -114,6 +116,7 @@ struct XenBlkDev { + int requests_finished; + + /* Persistent grants extension */ ++ gboolean feature_discard; + gboolean feature_persistent; + GTree *persistent_gnts; + unsigned int persistent_gnt_count; +@@ -232,6 +235,7 @@ static void ioreq_release(struct ioreq * + static int ioreq_parse(struct ioreq *ioreq) + { + struct XenBlkDev *blkdev = ioreq->blkdev; ++ struct blkif_request_discard *discard_req = (void *)&ioreq->req; + uintptr_t mem; + size_t len; + int i; +@@ -244,6 +248,10 @@ static int ioreq_parse(struct ioreq *ior + case BLKIF_OP_READ: + ioreq->prot = PROT_WRITE; /* to memory */ + break; ++ case BLKIF_OP_DISCARD: ++ ioreq->sector_num = discard_req->sector_number; ++ ioreq->nb_sectors = discard_req->nr_sectors; ++ return 0; + case BLKIF_OP_FLUSH_DISKCACHE: + ioreq->presync = 1; + if (!ioreq->req.nr_segments) { +@@ -521,6 +529,13 @@ static int ioreq_runio_qemu_aio(struct i + &ioreq->v, ioreq->v.size / BLOCK_SIZE, + qemu_aio_complete, ioreq); + break; ++ case BLKIF_OP_DISCARD: ++ bdrv_acct_start(blkdev->bs, &ioreq->acct, ioreq->nb_sectors * BLOCK_SIZE, BDRV_ACCT_WRITE); ++ ioreq->aio_inflight++; ++ bdrv_aio_discard(blkdev->bs, ++ ioreq->sector_num, ioreq->nb_sectors, ++ qemu_aio_complete, ioreq); ++ break; + default: + /* unknown operation (shouldn't happen -- parse catches this) */ + goto err; +@@ -699,6 +714,23 @@ static void blk_alloc(struct XenDevice * + } + } + ++static void blk_parse_discard(struct XenBlkDev *blkdev) ++{ ++ int flags = BDRV_O_UNMAP; ++#if 0 ++ char *s = xenstore_read_be_str(&blkdev->xendev, "toolstack-options-discard"); ++ ++ if (s && bdrv_parse_discard_flags(s, &flags) < 0) { ++ xen_be_printf(xendev, 0, "property toolstack-discard-options failed to parse: %s\n", s); ++ return; ++ } ++#endif ++ blkdev->feature_discard = !!(flags & BDRV_O_UNMAP); ++ if (!blkdev->feature_discard) ++ return; ++ xenstore_write_be_int(&blkdev->xendev, "feature-discard", 1); ++} ++ + static int blk_init(struct XenDevice *xendev) + { + struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); +@@ -766,6 +798,8 @@ static int blk_init(struct XenDevice *xe + xenstore_write_be_int(&blkdev->xendev, "feature-persistent", 1); + xenstore_write_be_int(&blkdev->xendev, "info", info); + ++ blk_parse_discard(blkdev); ++ + g_free(directiosafe); + return 0; + +@@ -801,6 +835,8 @@ static int blk_connect(struct XenDevice + qflags |= BDRV_O_RDWR; + readonly = false; + } ++ if (blkdev->feature_discard) ++ qflags |= BDRV_O_UNMAP; + + /* init qemu block driver */ + index = (blkdev->xendev.dev - 202 * 256) / 16; diff --git a/xen.changes b/xen.changes index e81a76a..416414c 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Wed Jan 16 13:11:32 MST 2014 - carnold@suse.com + +- Fix the spec file to build for old distros + The xm/xend toolstack will continue to be contained in xen-tools + for older openSUSE and sles distros but it will be contained in + xend-tools for os13.x + +------------------------------------------------------------------- +Wed Jan 15 19:55:32 CET 2014 - ohering@suse.de + +- fate#316071: add discard support for file backed storage (qdisk) + to qemu-upstream, enabled unconditionally + ------------------------------------------------------------------- Tue Jan 14 12:13:45 MST 2014 - carnold@suse.com diff --git a/xen.spec b/xen.spec index 09931ba..10725f9 100644 --- a/xen.spec +++ b/xen.spec @@ -31,11 +31,15 @@ ExclusiveArch: %ix86 x86_64 %arm aarch64 %else %ifarch x86_64 %define with_kmp 1 -%define with_xend 0 %define with_debug 1 %define with_stubdom 1 %define with_dom0_support 1 %define with_qemu_traditional 1 +%if %suse_version > 1230 +%define with_xend 1 +%else +%define with_xend 1 +%endif %else %define with_xend 0 %define with_stubdom 0 @@ -63,20 +67,22 @@ BuildRequires: fdupes BuildRequires: glib2-devel BuildRequires: libaio-devel BuildRequires: libbz2-devel +BuildRequires: libpixman-1-0-devel BuildRequires: libuuid-devel BuildRequires: libxml2-devel BuildRequires: libyajl-devel -BuildRequires: libpixman-1-0-devel BuildRequires: ncurses-devel BuildRequires: openssl-devel BuildRequires: python-devel BuildRequires: transfig +%if %suse_version >= 1030 BuildRequires: texinfo BuildRequires: texlive -BuildRequires: texlive-latex +%if %suse_version > 1220 BuildRequires: texlive-courier BuildRequires: texlive-dvips BuildRequires: texlive-helvetic +BuildRequires: texlive-latex BuildRequires: texlive-psnfss BuildRequires: texlive-times BuildRequires: tex(a4.sty) @@ -84,6 +90,12 @@ BuildRequires: tex(a4wide.sty) BuildRequires: tex(fancyhdr.sty) BuildRequires: tex(parskip.sty) BuildRequires: tex(setspace.sty) +%endif +%else +BuildRequires: te_ams +BuildRequires: te_latex +BuildRequires: tetex +%endif %if %suse_version >= 1230 BuildRequires: systemd %endif @@ -112,10 +124,14 @@ BuildRequires: glibc-devel-32bit BuildRequires: kernel-source BuildRequires: kernel-syms BuildRequires: module-init-tools +%if %suse_version >= 1230 BuildRequires: lndir +%else +BuildRequires: xorg-x11-util-devel +%endif %endif -Version: 4.4.0_01 +Version: 4.4.0_02 Release: 0 PreReq: %insserv_prereq %fillup_prereq Summary: Xen Virtualization: Hypervisor (aka VMM aka Microkernel) @@ -235,6 +251,7 @@ Patch380: pvdrv_emulation_control.patch Patch381: ioemu-disable-scsi.patch Patch382: ioemu-disable-emulated-ide-if-pv.patch Patch383: xenpaging.qemu.flush-cache.patch +Patch384: qemu-xen-upstream-blkif-discard.patch # Xend Patch400: xen.migrate.tools_set_migration_constraints_from_cmdline.patch Patch401: xen.migrate.tools_add_xm_migrate_--log_progress_option.patch @@ -412,6 +429,7 @@ Authors: %if %{?with_xend}0 +%if %suse_version > 1230 %package xend-tools Summary: Xen Virtualization: Control tools for domain 0 Group: System/Kernel @@ -437,6 +455,7 @@ In addition to this package you need to install kernel-xen, xen and xen-libs to use Xen. %endif %endif +%endif %package tools-domU Summary: Xen Virtualization: Control tools for domain U @@ -578,6 +597,7 @@ Authors: %patch381 -p1 %patch382 -p1 %patch383 -p1 +%patch384 -p1 # Xend %if %{?with_xend}0 %patch400 -p1 @@ -1184,7 +1204,9 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/*.so.* %{_mandir}/man8/*.8.gz %if %{?with_xend}0 +%if %suse_version > 1230 %files xend-tools +%endif %defattr(-,root,root) %ifnarch %arm aarch64 /etc/udev/rules.d/40-xend.rules @@ -1266,10 +1288,31 @@ fi %if %{?with_systemd}0 %{fillup_and_insserv -i -y -n xencommons xencommons} /bin/systemctl enable xencommons.service +%if %suse_version <= 1230 +%if %{?with_xend}0 +%{fillup_and_insserv -y -n xend xend} +/bin/systemctl enable xend.service +%endif +%endif %else %{fillup_and_insserv -y -n xencommons xencommons} +%if %suse_version <= 1230 +%if %{?with_xend}0 +# enable both xm (xend based) and xl (libxl based) +if /bin/ls /etc/init.d/rc3.d/S??xend > /dev/null 2>&1 ; then + if ! /bin/ls /etc/init.d/rc3.d/S??xencommons > /dev/null 2>&1 ; then + echo "postin %{name}-tools: Forcing insserv xencommons during package upgrade because xend was enabled." + echo "postin %{name}-tools: with xend" + fi + %{fillup_and_insserv -Y -n xencommons xencommons} +else + %{fillup_and_insserv -y -n xencommons xencommons} +fi +%{fillup_and_insserv -y -n xend xend} %endif -# +%endif +%endif + %ifnarch %arm aarch64 %if %{?with_systemd}0 %{fillup_and_insserv -i -y -n xendomains xendomains} @@ -1306,20 +1349,7 @@ if [ -f /usr/bin/qemu-io ]; then fi %endif -%preun tools -%if %{?with_systemd}0 -if [ $1 -eq 0 ]; then - /bin/systemctl disable xencommons.service - /bin/systemctl disable xendomains.service -fi -%else -%{stop_on_removal xendomains xencommons} -%endif - -%postun tools -%{insserv_cleanup} - -# Scripts only if creating the xend-tools package +%if %suse_version > 1230 %if %{?with_xend}0 %post xend-tools %if %{?with_systemd}0 @@ -1328,7 +1358,31 @@ fi %else %{fillup_and_insserv -y -n xend xend} %endif +%endif +%endif +%preun tools +%if %{?with_systemd}0 +if [ $1 -eq 0 ]; then + /bin/systemctl disable xencommons.service + /bin/systemctl disable xendomains.service +%if %suse_version <= 1230 +%if %{?with_xend}0 + /bin/systemctl disable xend.service +%endif +%endif +fi +%else +%{stop_on_removal xendomains xencommons} +%if %suse_version <= 1230 +%if %{?with_xend}0 +%{stop_on_removal xend} +%endif +%endif +%endif + +%if %suse_version > 1230 +%if %{?with_xend}0 %preun xend-tools %if %{?with_systemd}0 if [ $1 -eq 0 ]; then @@ -1337,17 +1391,47 @@ fi %else %{stop_on_removal xend} %endif +%endif +%endif +%postun tools +%if %suse_version <= 1230 +%if %{?with_xend}0 +%{restart_on_update xend} +%endif +%endif +%{insserv_cleanup} +%ifnarch %arm aarch64 +%if %suse_version <= 1230 +%if %{?with_xend}0 +if [ -f /usr/bin/qemu-img-xen ]; then + rm /usr/bin/qemu-img-xen +fi +if [ -f /usr/bin/qemu-nbd-xen ]; then + rm /usr/bin/qemu-nbd-xen +fi +%endif +%endif +%endif + +%if %suse_version > 1230 +%if %{?with_xend}0 %postun xend-tools %{restart_on_update xend} %{insserv_cleanup} +if [ -f /usr/bin/qemu-img-xen ]; then + rm /usr/bin/qemu-img-xen +fi +if [ -f /usr/bin/qemu-nbd-xen ]; then + rm /usr/bin/qemu-nbd-xen +fi +%endif %endif %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig -# with_dom0_support %endif %changelog