From nobody Wed May 14 06:07:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525880247528885.6105982194456; Wed, 9 May 2018 08:37:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF186300370F; Wed, 9 May 2018 15:37:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6BD9B2010CCF; Wed, 9 May 2018 15:37:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 10AC01808850; Wed, 9 May 2018 15:37:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w49FbNQn010598 for ; Wed, 9 May 2018 11:37:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7554065325; Wed, 9 May 2018 15:37:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6037365321 for ; Wed, 9 May 2018 15:37:16 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBB7319D241 for ; Wed, 9 May 2018 15:37:15 +0000 (UTC) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w49FYfXa023881 for ; Wed, 9 May 2018 11:37:15 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hv38utbs9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 May 2018 11:37:15 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 May 2018 16:37:12 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 9 May 2018 16:37:11 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w49FWMXR51118150 for ; Wed, 9 May 2018 15:37:10 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 56636B758E for ; Wed, 9 May 2018 15:46:34 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E488B720E for ; Wed, 9 May 2018 15:46:30 +0100 (BST) Received: from marc-ibm.boeblingen.de.ibm.com (unknown [9.152.224.71]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 9 May 2018 15:46:29 +0100 (BST) From: Marc Hartmayer To: Date: Wed, 9 May 2018 16:56:11 +0200 In-Reply-To: <20180509145622.23049-1-mhartmay@linux.vnet.ibm.com> References: <20180509145622.23049-1-mhartmay@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18050915-0020-0000-0000-0000041AD00D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050915-0021-0000-0000-000042B0107E Message-Id: <20180509145622.23049-2-mhartmay@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-09_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805090146 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 09 May 2018 15:37:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 09 May 2018 15:37:16 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'mhartmay@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/12] virsh: Force boot emulation is only required for virDomainCreateWithFlags X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 09 May 2018 15:37:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The force boot emulation is only required for virDomainCreateWithFlags as the flag VIR_DOMAIN_START_FORCE_BOOT was introduced with the commit 27c85260532f879be5674a4eed0811c21fd34f94 (2011). But virDomainCreateXMLWithFiles is newer and therefore already had support for VIR_DOMAIN_START_FORCE_BOOT. This means there is now no second call with VIR_DOMAIN_START_FORCE_BOOT removed from flags for virDomainCreateXMLWithFiles in case the first call fails. virDomainCreateXMLWithFiles was introduced with commit d76227bea35cc49374a94414f6d46e3493ac2a52 (2013). This patch takes this into account and simplifies the function. In addition, it's now easier to extend the function. Signed-off-by: Marc Hartmayer Reviewed-by: Boris Fiuczynski --- tools/virsh-domain.c | 52 ++++++++++++++++++++++++++++--------------------= ---- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 598d2fa4a4bd..7cf8373f05bc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4038,40 +4038,44 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "force-boot")) flags |=3D VIR_DOMAIN_START_FORCE_BOOT; =20 - /* We can emulate force boot, even for older servers that reject it. = */ - if (flags & VIR_DOMAIN_START_FORCE_BOOT) { - if ((nfds ? - virDomainCreateWithFiles(dom, nfds, fds, flags) : - virDomainCreateWithFlags(dom, flags)) =3D=3D 0) - goto started; - if (last_error->code !=3D VIR_ERR_NO_SUPPORT && - last_error->code !=3D VIR_ERR_INVALID_ARG) { - vshReportError(ctl); - goto cleanup; - } - vshResetLibvirtError(); - rc =3D virDomainHasManagedSaveImage(dom, 0); - if (rc < 0) { - /* No managed save image to remove */ - vshResetLibvirtError(); - } else if (rc > 0) { - if (virDomainManagedSaveRemove(dom, 0) < 0) { + /* Prefer older API unless we have to pass extra parameters */ + if (nfds) { + rc =3D virDomainCreateWithFiles(dom, nfds, fds, flags); + } else if (flags) { + rc =3D virDomainCreateWithFlags(dom, flags); + /* We can emulate force boot, even for older servers that + * reject it. */ + if (rc < 0 && flags & VIR_DOMAIN_START_FORCE_BOOT) { + if (last_error->code !=3D VIR_ERR_NO_SUPPORT && + last_error->code !=3D VIR_ERR_INVALID_ARG) { vshReportError(ctl); goto cleanup; } + vshResetLibvirtError(); + rc =3D virDomainHasManagedSaveImage(dom, 0); + if (rc < 0) { + /* No managed save image to remove */ + vshResetLibvirtError(); + } else if (rc > 0) { + if (virDomainManagedSaveRemove(dom, 0) < 0) { + vshReportError(ctl); + goto cleanup; + } + } + + /* now try it again without the force boot flag */ + flags &=3D ~VIR_DOMAIN_START_FORCE_BOOT; + rc =3D virDomainCreateWithFlags(dom, flags); } - flags &=3D ~VIR_DOMAIN_START_FORCE_BOOT; + } else { + rc =3D virDomainCreate(dom); } =20 - /* Prefer older API unless we have to pass a flag. */ - if ((nfds ? virDomainCreateWithFiles(dom, nfds, fds, flags) : - (flags ? virDomainCreateWithFlags(dom, flags) - : virDomainCreate(dom))) < 0) { + if (rc < 0) { vshError(ctl, _("Failed to start domain %s"), virDomainGetName(dom= )); goto cleanup; } =20 - started: vshPrintExtra(ctl, _("Domain %s started\n"), virDomainGetName(dom)); #ifndef WIN32 --=20 2.13.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list