From nobody Wed May 15 23:53:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1648115353; cv=none; d=zohomail.com; s=zohoarc; b=OxM5yP8PnTno1RrZjBwa62oTZaeWT7SqHYHHm4cokevgk7YoNAYwk1vTROsRW00ClwqbsJVtfZipriDvPwFlYc5fggv3d/yX6OcWimUc7teBuV0srruMEGrlAIMRCPKrXHwS3BcowJtfFQUWHf2bnpYEuezOJuRaH4DB6m2Jz2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648115353; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EPdA48/duhJJmxOV9gEHYudZEQ5ymFO58A18PmkqAsE=; b=UfOYMmIHdEf6Al9/i/ZdwP6NVoI7YgGAT65y6WYwC4J1giiGOwfNqDwWjT9JftkpX8eGoZVsDMdCAF4P38rYFgerNwNoEBjII1o7gg8d5xknUzadHYKjN/lmxx8ytb/oAIX4bFxzzL0D3s1ZjvqK7P6AXA5FB+7UHP6T9rbsa/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1648115353032752.8060336816172; Thu, 24 Mar 2022 02:49:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-wwpqRSMkNN-5S_soZTNkcg-1; Thu, 24 Mar 2022 05:49:08 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 608F81C068EF; Thu, 24 Mar 2022 09:49:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF79458A48C; Thu, 24 Mar 2022 09:49:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6B28C1940360; Thu, 24 Mar 2022 09:49:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 563BD1940347 for ; Thu, 24 Mar 2022 09:49:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 49156111F3C7; Thu, 24 Mar 2022 09:49:01 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.195.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5F4F112132C; Thu, 24 Mar 2022 09:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648115352; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EPdA48/duhJJmxOV9gEHYudZEQ5ymFO58A18PmkqAsE=; b=EdIYLZGMLHzD/4zY1ysk5fhb9OGSbJ/qywJrt/uGlbmwaJQXf6sFHo6Z2lLWkeC+OLjwR/ 176vo4D5+/nLWpVsfYdqWcJtBsfv0SJRHr9Ly8huzzBpq3hJzT+ODlh1GoHr+q0g4lPuOi j8WBfHJ/kYAco32XbPfYsOc87rP4GEI= X-MC-Unique: wwpqRSMkNN-5S_soZTNkcg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Paolo Bonzini To: libvir-list@redhat.com Subject: [PATCH 1/2] domain: add tsc.on_reboot element Date: Thu, 24 Mar 2022 10:48:38 +0100 Message-Id: <20220324094839.130251-2-pbonzini@redhat.com> In-Reply-To: <20220324094839.130251-1-pbonzini@redhat.com> References: <20220324094839.130251-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648115353855100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Some versions of Windows hang on reboot if their TSC value is greater than 2^54. The workaround is to reset the TSC to a small value. Add to the domain configuration an attribute for this. It can be used by QEMU and in principle also by ESXi, which has a property called monitor_control.enable_softResetClearTSC as well. Signed-off-by: Paolo Bonzini Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 4 ++++ src/conf/domain_conf.c | 22 ++++++++++++++++++++++ src/conf/domain_conf.h | 10 ++++++++++ src/conf/schemas/domaincommon.rng | 9 +++++++++ 4 files changed, 45 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index d188de4858..c9319e42ac 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2241,6 +2241,10 @@ Windows, however, expects it to be in so called 'loc= altime'. ``frequency`` The ``frequency`` attribute is an unsigned integer specifying the frequency at which ``name=3D"tsc"`` runs. + ``on_reboot`` + The ``on_reboot`` attribute controls how the ``name=3D"tsc"`` timer = behaves + when the VM is reset, and can be "default", "clear" or "keep". The r= eset + behavior of other timers is hardcoded, and depends on the type of ti= mer. ``mode`` The ``mode`` attribute controls how the ``name=3D"tsc"`` timer is ma= naged, and can be "auto", "native", "emulate", "paravirt", or "smpsafe". Ot= her diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 153954a0b0..1893b8bbca 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1217,6 +1217,13 @@ VIR_ENUM_IMPL(virDomainTimerMode, "smpsafe", ); =20 +VIR_ENUM_IMPL(virDomainTimerRebootMode, + VIR_DOMAIN_TIMER_REBOOT_MODE_LAST, + "default", + "keep", + "clear", +); + VIR_ENUM_IMPL(virDomainStartupPolicy, VIR_DOMAIN_STARTUP_POLICY_LAST, "default", @@ -12022,6 +12029,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, g_autofree char *tickpolicy =3D NULL; g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; + g_autofree char *reboot =3D NULL; =20 def =3D g_new0(virDomainTimerDef, 1); =20 @@ -12080,6 +12088,15 @@ virDomainTimerDefParseXML(xmlNodePtr node, } } =20 + reboot =3D virXMLPropString(node, "on_reboot"); + if (reboot !=3D NULL) { + if ((def->reboot =3D virDomainTimerRebootModeTypeFromString(reboot= )) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown timer reboot mode '%s'"), reboot); + goto error; + } + } + catchup =3D virXPathNode("./catchup", ctxt); if (catchup !=3D NULL) { ret =3D virXPathULong("string(./catchup/@threshold)", ctxt, @@ -26151,6 +26168,11 @@ virDomainTimerDefFormat(virBuffer *buf, virBufferAsprintf(&timerAttr, " mode=3D'%s'", virDomainTimerModeTypeToString(def->mode)); } + + if (def->reboot) { + virBufferAsprintf(&timerAttr, " on_reboot=3D'%s'", + virDomainTimerRebootModeTypeToString(def->mo= de)); + } } =20 if (def->catchup.threshold > 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b69abfa270..3618410f6c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2408,6 +2408,14 @@ typedef enum { VIR_DOMAIN_TIMER_MODE_LAST } virDomainTimerModeType; =20 +typedef enum { + VIR_DOMAIN_TIMER_REBOOT_MODE_DEFAULT =3D 0, + VIR_DOMAIN_TIMER_REBOOT_MODE_KEEP, + VIR_DOMAIN_TIMER_REBOOT_MODE_CLEAR, + + VIR_DOMAIN_TIMER_REBOOT_MODE_LAST +} virDomainTimerRebootModeType; + typedef enum { VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC =3D 0, VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO, @@ -2439,6 +2447,7 @@ struct _virDomainTimerDef { /* frequency & mode are only valid for name=3D'tsc' */ unsigned long long frequency; /* in Hz, unspecified =3D 0 */ int mode; /* enum virDomainTimerModeType */ + int reboot; /* enum virDomainTimerRebootModeType */ }; =20 typedef enum { @@ -4032,6 +4041,7 @@ VIR_ENUM_DECL(virDomainClockBasis); VIR_ENUM_DECL(virDomainTimerName); VIR_ENUM_DECL(virDomainTimerTrack); VIR_ENUM_DECL(virDomainTimerTickpolicy); +VIR_ENUM_DECL(virDomainTimerRebootMode); VIR_ENUM_DECL(virDomainTimerMode); VIR_ENUM_DECL(virDomainCpuPlacementMode); =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 9c1b64a644..10d0404889 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1285,6 +1285,15 @@ + + + + default + clear + keep + + + --=20 2.35.1 From nobody Wed May 15 23:53:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1648115353; cv=none; d=zohomail.com; s=zohoarc; b=NDf1dzFPseJBVaV14bn1pZect7xP6wiP4gtU8IdjdKZVToeG1hG8StEXOOQDnwOAgf+sRI+6xn50JLOvAacWgM+TaW4lm0ghLPSQBSm0+ph3o42Bz5apYdXzSyRtesXLShboNCUNGSbRdqBHZTZ8LzItNpRWMIwD2cI9f94QMGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648115353; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oyBWOtZgFYrLVdLHBfoWMKLj2sQ6ZPqr/q/uV81MZbI=; b=Q3iyVQ+yuZbvg0U6wllhuwGpNgZzY3QlPsCmrnRt7c3m+ooP5S9CNkGuVtlhwnqj0iIGd+TDqQ41mZD9qqFGmrg0nMvLb49tZa6nayUa6FkWHUb2qeomErptHO620/fRLBf07xX9EIgwCmQmGh4Dl3AXrbzRo+VeVAfQWmQKXyw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1648115353015242.56276098256956; Thu, 24 Mar 2022 02:49:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-369-0JbwCqXnPs2hWRkfVn0ChA-1; Thu, 24 Mar 2022 05:49:08 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63372833963; Thu, 24 Mar 2022 09:49:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0524958A48D; Thu, 24 Mar 2022 09:49:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 360F21940356; Thu, 24 Mar 2022 09:49:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 381F8194035F for ; Thu, 24 Mar 2022 09:49:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 29C92111F3C1; Thu, 24 Mar 2022 09:49:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.195.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E0DF112132C; Thu, 24 Mar 2022 09:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648115351; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oyBWOtZgFYrLVdLHBfoWMKLj2sQ6ZPqr/q/uV81MZbI=; b=VogztWC32rdez8a8e2JvttwREpuM99zbt+NsXN7ljA6yTVUz1uG7Mvr+0Q6gqyQXwNc0Nm 3fDCuEQtCn57vmMKu9la2YF8ukSQcxPX/7OADdpyLnJ8NpEtnN7Znxy6OWB0UfCndAHR1V xgxJt9JijfooxOckAh+v5fOPypZBu+c= X-MC-Unique: 0JbwCqXnPs2hWRkfVn0ChA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Paolo Bonzini To: libvir-list@redhat.com Subject: [PATCH 2/2] qemu: add support for tsc.on_reboot element Date: Thu, 24 Mar 2022 10:48:39 +0100 Message-Id: <20220324094839.130251-3-pbonzini@redhat.com> In-Reply-To: <20220324094839.130251-1-pbonzini@redhat.com> References: <20220324094839.130251-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648115353881100002 Content-Type: text/plain; charset="utf-8"; x-default="true" QEMU 7.0.0 adds a new property tsc-clear-on-reset to x86 CPU, corresponding to Libvirt's element. Plumb it in the validatio= n, command line handling and tests. Signed-off-by: Paolo Bonzini Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 4 +++ src/qemu/qemu_validate.c | 36 +++++++++++++------ .../caps_7.0.0.x86_64.replies | 4 +++ .../caps_7.0.0.x86_64.xml | 1 + ...uency.args =3D> cpu-tsc-clear-on-reset.args} | 2 +- ... cpu-tsc-clear-on-reset.x86_64-7.0.0.args} | 6 ++-- ...equency.xml =3D> cpu-tsc-clear-on-reset.xml} | 2 +- tests/qemuxml2argvtest.c | 2 ++ 10 files changed, 44 insertions(+), 16 deletions(-) copy tests/qemuxml2argvdata/{cpu-tsc-frequency.args =3D> cpu-tsc-clear-on-= reset.args} (97%) copy tests/qemuxml2argvdata/{virtio-rng-builtin.x86_64-latest.args =3D> cp= u-tsc-clear-on-reset.x86_64-7.0.0.args} (77%) copy tests/qemuxml2argvdata/{cpu-tsc-frequency.xml =3D> cpu-tsc-clear-on-r= eset.xml} (95%) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 32980e7330..d22bbee70e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -668,6 +668,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 425 */ "blockdev.nbd.tls-hostname", /* QEMU_CAPS_BLOCKDEV_NBD_TLS_H= OSTNAME */ + "x86-cpu.tsc-clear-on-reset", /* QEMU_CAPS_X86_CPU_TSC_CLEAR= _ON_RESET */ ); =20 =20 @@ -1775,6 +1776,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjec= tPropsMemoryBackendMemfd[] static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMaxCPU[] =3D { { "unavailable-features", QEMU_CAPS_CPU_UNAVAILABLE_FEATURES }, { "kvm-no-adjvtime", QEMU_CAPS_CPU_KVM_NO_ADJVTIME }, + { "tsc-clear-on-reset", QEMU_CAPS_X86_CPU_TSC_CLEAR_ON_RESET }, { "migratable", QEMU_CAPS_CPU_MIGRATABLE }, }; =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 0a215a11d5..7aee73a725 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -643,6 +643,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 425 */ QEMU_CAPS_BLOCKDEV_NBD_TLS_HOSTNAME, /* tls hostname can be overriden = for NBD clients */ + QEMU_CAPS_X86_CPU_TSC_CLEAR_ON_RESET, /* x86-cpu.tsc-clear-on-reset */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c836799888..8ecede0ade 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6613,6 +6613,10 @@ qemuBuildCpuCommandLine(virCommand *cmd, case VIR_DOMAIN_TIMER_NAME_TSC: if (timer->frequency > 0) virBufferAsprintf(&buf, ",tsc-frequency=3D%llu", timer->fr= equency); + if (timer->reboot =3D=3D VIR_DOMAIN_TIMER_REBOOT_MODE_CLEAR) + virBufferAddLit(&buf, ",tsc-clear-on-reset=3Don"); + else if (timer->reboot =3D=3D VIR_DOMAIN_TIMER_REBOOT_MODE_KEE= P) + virBufferAddLit(&buf, ",tsc-clear-on-reset=3Doff"); break; case VIR_DOMAIN_TIMER_NAME_ARMVTIMER: switch (timer->tickpolicy) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index f27e480696..c4ab2976dc 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -396,10 +396,11 @@ static int qemuValidateDomainDefClockTimers(const virDomainDef *def, virQEMUCaps *qemuCaps) { + virDomainTimerDef *timer; size_t i; =20 for (i =3D 0; i < def->clock.ntimers; i++) { - virDomainTimerDef *timer =3D def->clock.timers[i]; + timer =3D def->clock.timers[i]; =20 switch ((virDomainTimerNameType)timer->name) { case VIR_DOMAIN_TIMER_NAME_PLATFORM: @@ -409,20 +410,25 @@ qemuValidateDomainDefClockTimers(const virDomainDef *= def, return -1; =20 case VIR_DOMAIN_TIMER_NAME_TSC: - case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: - case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: - if (!ARCH_IS_X86(def->os.arch) && timer->present =3D=3D VIR_TR= ISTATE_BOOL_YES) { + if (!ARCH_IS_X86(def->os.arch) && timer->present =3D=3D VIR_TR= ISTATE_BOOL_YES) + goto no_support; + + if (timer->reboot !=3D VIR_DOMAIN_TIMER_REBOOT_MODE_DEFAULT && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_X86_CPU_TSC_CLEAR_ON_R= ESET)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Configuring the '%s' timer is not suppor= ted " - "for virtType=3D%s arch=3D%s machine=3D%s= guests"), - virDomainTimerNameTypeToString(timer->name), - virDomainVirtTypeToString(def->virtType), - virArchToString(def->os.arch), - def->os.machine); + _("Configuring the '%s' timer to reset on r= eboot is not supported " + "with this QEMU binary"), + virDomainTimerNameTypeToString(timer->name)= ); return -1; } break; =20 + case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: + case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: + if (!ARCH_IS_X86(def->os.arch) && timer->present =3D=3D VIR_TR= ISTATE_BOOL_YES) + goto no_support; + break; + case VIR_DOMAIN_TIMER_NAME_LAST: break; =20 @@ -540,6 +546,16 @@ qemuValidateDomainDefClockTimers(const virDomainDef *d= ef, } =20 return 0; + + no_support: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Configuring the '%s' timer is not supported " + "for virtType=3D%s arch=3D%s machine=3D%s guests"), + virDomainTimerNameTypeToString(timer->name), + virDomainVirtTypeToString(def->virtType), + virArchToString(def->os.arch), + def->os.machine); + return -1; } =20 =20 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.replies b/tests/q= emucapabilitiesdata/caps_7.0.0.x86_64.replies index 82ccbab6eb..d919caf7f3 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.replies +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.replies @@ -28849,6 +28849,10 @@ { "name": "sse4_1", "type": "bool" + }, + { + "name": "tsc-clear-on-reset", + "type": "bool" } ], "id": "libvirt-41" diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.0.0.x86_64.xml index 0f34a341af..d36237364f 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -244,6 +244,7 @@ + 6002050 0 43100243 diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2= argvdata/cpu-tsc-clear-on-reset.args similarity index 97% copy from tests/qemuxml2argvdata/cpu-tsc-frequency.args copy to tests/qemuxml2argvdata/cpu-tsc-clear-on-reset.args index 4a032f5d85..f2b8a98968 100644 --- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args +++ b/tests/qemuxml2argvdata/cpu-tsc-clear-on-reset.args @@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=3Dnone \ -object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-QEMU= Guest1/master-key.aes \ -machine pc,usb=3Doff,dump-guest-core=3Doff \ -accel kvm \ --cpu Haswell,vme=3Don,ds=3Don,acpi=3Don,ss=3Don,ht=3Don,tm=3Don,pbe=3Don,d= tes64=3Don,monitor=3Don,ds-cpl=3Don,vmx=3Don,smx=3Don,est=3Don,tm2=3Don,xtp= r=3Don,pdcm=3Don,f16c=3Don,rdrand=3Don,pdpe1gb=3Don,abm=3Don,lahf-lm=3Don,i= nvtsc=3Don,tsc-frequency=3D4567890000 \ +-cpu Haswell,vme=3Don,ds=3Don,acpi=3Don,ss=3Don,ht=3Don,tm=3Don,pbe=3Don,d= tes64=3Don,monitor=3Don,ds-cpl=3Don,vmx=3Don,smx=3Don,est=3Don,tm2=3Don,xtp= r=3Don,pdcm=3Don,f16c=3Don,rdrand=3Don,pdpe1gb=3Don,abm=3Don,lahf-lm=3Don,i= nvtsc=3Don,tsc-clear-on-reset=3Don \ -m 214 \ -realtime mlock=3Doff \ -smp 1,sockets=3D1,cores=3D1,threads=3D1 \ diff --git a/tests/qemuxml2argvdata/virtio-rng-builtin.x86_64-latest.args b= /tests/qemuxml2argvdata/cpu-tsc-clear-on-reset.x86_64-7.0.0.args similarity index 77% copy from tests/qemuxml2argvdata/virtio-rng-builtin.x86_64-latest.args copy to tests/qemuxml2argvdata/cpu-tsc-clear-on-reset.x86_64-7.0.0.args index a0aeb74319..59f1d66ed4 100644 --- a/tests/qemuxml2argvdata/virtio-rng-builtin.x86_64-latest.args +++ b/tests/qemuxml2argvdata/cpu-tsc-clear-on-reset.x86_64-7.0.0.args @@ -10,9 +10,9 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -name guest=3DQEMUGuest1,debug-threads=3Don \ -S \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-QEMUGuest1/master-key.aes"}' \ --machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram \ +-machine pc-i440fx-7.0,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc= .ram \ -accel kvm \ --cpu qemu64 \ +-cpu EPYC-Rome,x2apic=3Don,tsc-deadline=3Don,hypervisor=3Don,tsc-adjust=3D= on,stibp=3Don,arch-capabilities=3Don,ssbd=3Don,xsaves=3Don,cmp-legacy=3Don,= amd-ssbd=3Don,virt-ssbd=3Don,svme-addr-chk=3Don,rdctl-no=3Don,skip-l1dfl-vm= entry=3Don,mds-no=3Don,pschange-mc-no=3Don,invtsc=3Don,tsc-clear-on-reset= =3Don \ -m 214 \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ -overcommit mem-lock=3Doff \ @@ -30,7 +30,5 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ --object '{"qom-type":"rng-builtin","id":"objrng0"}' \ --device '{"driver":"virtio-rng-pci","rng":"objrng0","id":"rng0","bus":"pci= .0","addr":"0x3"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.xml b/tests/qemuxml2a= rgvdata/cpu-tsc-clear-on-reset.xml similarity index 95% copy from tests/qemuxml2argvdata/cpu-tsc-frequency.xml copy to tests/qemuxml2argvdata/cpu-tsc-clear-on-reset.xml index afaef6e8e5..2521349ce7 100644 --- a/tests/qemuxml2argvdata/cpu-tsc-frequency.xml +++ b/tests/qemuxml2argvdata/cpu-tsc-clear-on-reset.xml @@ -18,7 +18,7 @@ - + destroy restart diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e7fecb24d3..9d5aba85a1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2094,6 +2094,8 @@ mymain(void) DO_TEST("cpu-Haswell-noTSX", QEMU_CAPS_KVM); DO_TEST_NOCAPS("cpu-host-model-cmt"); DO_TEST_CAPS_VER("cpu-host-model-cmt", "4.0.0"); + DO_TEST("cpu-tsc-clear-on-reset", QEMU_CAPS_X86_CPU_TSC_CLEAR_ON_RESET= ); + DO_TEST_CAPS_VER("cpu-tsc-clear-on-reset", "7.0.0"); DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM); DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0"); DO_TEST_CAPS_VER("cpu-translation", "4.0.0"); --=20 2.35.1