From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Subject: Re: [PATCH v8 21/21] libxl: add support for migrating HVM guests without a device model Date: Thu, 26 Nov 2015 19:10:56 +0100 Message-ID: <56574B30.20700@citrix.com> References: <1446825955-11842-1-git-send-email-roger.pau@citrix.com> <1446825955-11842-22-git-send-email-roger.pau@citrix.com> <56437789.40905@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a210t-0008H5-Uz for xen-devel@lists.xenproject.org; Thu, 26 Nov 2015 18:11:24 +0000 In-Reply-To: <56437789.40905@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper , xen-devel@lists.xenproject.org Cc: Ian Jackson , Wei Liu , Ian Campbell List-Id: xen-devel@lists.xenproject.org El 11/11/15 a les 18.14, Andrew Cooper ha escrit: > On 06/11/15 16:05, Roger Pau Monne wrote: >> diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c >> index 52a60d7..0a6eaf9 100644 >> --- a/tools/libxl/libxl_stream_write.c >> +++ b/tools/libxl/libxl_stream_write.c >> @@ -232,6 +232,9 @@ void libxl__stream_write_start(libxl__egc *egc, >> stream->emu_sub_hdr.id = EMULATOR_QEMU_UPSTREAM; >> break; >> >> + case LIBXL_DEVICE_MODEL_VERSION_NONE: >> + break; >> + > > This (in principle) leaves stream->emu_sub_hdr.id uninitialised > (although its value will be zero because of libxl__stream_write_init()). > > I would be tempted to (ab)use EMULATOR_UNKNOWN here and have > setup_emulator_write() assert id != UNKNOWN, to catch calls which slip > through the cracks. This seems fine to me and I've implemented it. > >> default: >> rc = ERROR_FAIL; >> LOG(ERROR, "Unknown emulator for HVM domain"); >> @@ -359,6 +362,12 @@ static void write_emulator_xenstore_record(libxl__egc *egc, >> char *buf = NULL; >> uint32_t len = 0; >> >> + if (libxl__device_model_version_running(gc, dss->domid) == >> + LIBXL_DEVICE_MODEL_VERSION_NONE) { >> + emulator_xenstore_record_done(egc, stream); >> + return; >> + } >> + > > libxl__device_model_version_running() performs a xenstore action, which > is a steep overhead for constant information. > > It would be better to introduce a new field in libxl__stream_write_state > and cache libxl__device_model_version_running() once in > libxl__stream_write_start(). You can then also use that for an > assertion in setup_emulator_write() Right, so I've ended up adding two asserts in setup_emulator_write: assert(stream->emu_sub_hdr.id != EMULATOR_UNKNOWN); assert(stream->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE); Roger.