From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shriram Rajagopalan Subject: Re: [PATCH v3 2/2] libxl: save/restore qemu's physmap Date: Mon, 30 Jan 2012 10:02:56 -0800 Message-ID: References: <1327942455-23587-2-git-send-email-stefano.stabellini@eu.citrix.com> Reply-To: rshriram@cs.ubc.ca Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1863908327525484614==" Return-path: In-Reply-To: <1327942455-23587-2-git-send-email-stefano.stabellini@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: xen-devel@lists.xensource.com, Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org --===============1863908327525484614== Content-Type: multipart/alternative; boundary=000e0ce040448c852104b7c2aaf8 --000e0ce040448c852104b7c2aaf8 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jan 30, 2012 at 8:54 AM, Stefano Stabellini < stefano.stabellini@eu.citrix.com> wrote: > + > +static int libxl__toolstack_restore(uint32_t domid, uint8_t *buf, > + uint32_t size, void *data) > +{ > + libxl__gc *gc = (libxl__gc *) data; > + int i, ret; > + uint8_t *ptr = buf; > + uint32_t count = 0, version = 0; > + struct libxl__physmap_info* pi; > + > + if (size < sizeof(version) + sizeof(count)) > + return -1; > + > + memcpy(&version, ptr, sizeof(version)); > + ptr += sizeof(version); > + > + if (version != TOOLSTACK_SAVE_VERSION) > + return -1; > + > + memcpy(&count, ptr, sizeof(count)); > + ptr += sizeof(count); > + > + if (size < sizeof(version) + sizeof(count) + > + count * (sizeof(struct libxl__physmap_info))) > + return -1; > + > + for (i = 0; i < count; i++) { > + pi = (struct libxl__physmap_info*) ptr; > + ptr += sizeof(struct libxl__physmap_info) + pi->namelen; > + > + ret = libxl__xs_write(gc, 0, libxl__sprintf(gc, > + > "/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr", > + domid, pi->phys_offset), "%"PRIx64, pi->start_addr); > + if (ret) > + return -1; > + ret = libxl__xs_write(gc, 0, libxl__sprintf(gc, > + > "/local/domain/0/device-model/%d/physmap/%"PRIx64"/size", > + domid, pi->phys_offset), "%"PRIx64, pi->size); > + if (ret) > + return -1; > + if (pi->namelen > 0) { > + ret = libxl__xs_write(gc, 0, libxl__sprintf(gc, > + > "/local/domain/0/device-model/%d/physmap/%"PRIx64"/name", > + domid, pi->phys_offset), "%s", pi->name); > + if (ret) > + return -1; > + } > + } > + return 0; > +} > + > Sorry if this sounds silly. Is the save/restore of Qemu Physmap equivalent to save/restore of the Qemu Device Model ? --000e0ce040448c852104b7c2aaf8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, Jan 30, 2012 at 8:54 AM, Stefano Stabell= ini <stefano.stabellini@eu.citrix.com> wrote:
+
+static int libxl__toolstack_restore(uint32_t domid, uint8_t *buf,
+ =A0 =A0 =A0 =A0uint32_t size, void *data)
+{
+ =A0 =A0libxl__gc *gc =3D (libxl__gc *) data;
+ =A0 =A0int i, ret;
+ =A0 =A0uint8_t *ptr =3D buf;
+ =A0 =A0uint32_t count =3D 0, version =3D 0;
+ =A0 =A0struct libxl__physmap_info* pi;
+
+ =A0 =A0if (size < sizeof(version) + sizeof(count))
+ =A0 =A0 =A0 =A0return -1;
+
+ =A0 =A0memcpy(&version, ptr, sizeof(version));
+ =A0 =A0ptr +=3D sizeof(version);
+
+ =A0 =A0if (version !=3D TOOLSTACK_SAVE_VERSION)
+ =A0 =A0 =A0 =A0return -1;
+
+ =A0 =A0memcpy(&count, ptr, sizeof(count));
+ =A0 =A0ptr +=3D sizeof(count);
+
+ =A0 =A0if (size < sizeof(version) + sizeof(count) +
+ =A0 =A0 =A0 =A0 =A0 =A0count * (sizeof(struct libxl__physmap_info)))
+ =A0 =A0 =A0 =A0return -1;
+
+ =A0 =A0for (i =3D 0; i < count; i++) {
+ =A0 =A0 =A0 =A0pi =3D (struct libxl__physmap_info*) ptr;
+ =A0 =A0 =A0 =A0ptr +=3D sizeof(struct libxl__physmap_info) + pi->namel= en;
+
+ =A0 =A0 =A0 =A0ret =3D libxl__xs_write(gc, 0, libxl__sprintf(gc,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"/local/domain/0/device-model= /%d/physmap/%"PRIx64"/start_addr",
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0domid, pi->phys_offset), "= %"PRIx64, pi->start_addr);
+ =A0 =A0 =A0 =A0if (ret)
+ =A0 =A0 =A0 =A0 =A0 =A0return -1;
+ =A0 =A0 =A0 =A0ret =3D libxl__xs_write(gc, 0, libxl__sprintf(gc,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"/local/domain/0/device-model= /%d/physmap/%"PRIx64"/size",
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0domid, pi->phys_offset), "= %"PRIx64, pi->size);
+ =A0 =A0 =A0 =A0if (ret)
+ =A0 =A0 =A0 =A0 =A0 =A0return -1;
+ =A0 =A0 =A0 =A0if (pi->namelen > 0) {
+ =A0 =A0 =A0 =A0 =A0 =A0ret =3D libxl__xs_write(gc, 0, libxl__sprintf(gc,<= br> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"/local/domain/0/devi= ce-model/%d/physmap/%"PRIx64"/name",
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0domid, pi->phys_offset)= , "%s", pi->name);
+ =A0 =A0 =A0 =A0 =A0 =A0if (ret)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -1;
+ =A0 =A0 =A0 =A0}
+ =A0 =A0}
+ =A0 =A0return 0;
+}
+


Sorry if this sounds silly. Is the save/res= tore of Qemu Physmap equivalent to
save/restore of the Qemu Device Model= ?
--000e0ce040448c852104b7c2aaf8-- --===============1863908327525484614== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1863908327525484614==--