From nobody Wed May 14 06:11:19 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 1525880167344466.8782511339796; Wed, 9 May 2018 08:36:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 074FE81DFE; Wed, 9 May 2018 15:36:05 +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 96418611A9; Wed, 9 May 2018 15:36:04 +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 35F91180BAE6; Wed, 9 May 2018 15:36:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w49Fa1uq010147 for ; Wed, 9 May 2018 11:36:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DF0730001E0; Wed, 9 May 2018 15:36:01 +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 04D6530001DB for ; Wed, 9 May 2018 15:35:59 +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 18ED45277B for ; Wed, 9 May 2018 15:35:58 +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 w49FYg4V023919 for ; Wed, 9 May 2018 11:35:57 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hv38ut98k-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 May 2018 11:35:57 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 May 2018 16:35:54 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 9 May 2018 16:35:51 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w49FWOUo46858420 for ; Wed, 9 May 2018 15:35:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21C5BAE7DA for ; Wed, 9 May 2018 15:46:42 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3BB6AE5EE for ; Wed, 9 May 2018 15:46:41 +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:41 +0100 (BST) From: Marc Hartmayer To: Date: Wed, 9 May 2018 16:56:21 +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-0008-0000-0000-000004F4CD69 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050915-0009-0000-0000-00001E8916AC Message-Id: <20180509145622.23049-12-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:35:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 09 May 2018 15:35:58 +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.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/12] virsh: Add with-{bootdevice, kernel, initrd, cmdline} options for start 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 09 May 2018 15:36:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add the options with-bootdevice, with-kernel, with-initrd, and with-cmdline to 'virsh start'. They allow to temporarily boot from another boot device, to use another kernel, initrd, and cmdline than defined in the persistent domain definition. Signed-off-by: Marc Hartmayer Reviewed-by: Boris Fiuczynski --- tools/virsh-domain.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh.pod | 14 +++++++++ 2 files changed, 98 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7cf8373f05bc..3cb597b90937 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3953,6 +3953,25 @@ static const vshCmdOptDef opts_start[] =3D { .type =3D VSH_OT_STRING, .help =3D N_("pass file descriptors N,M,... to the guest") }, + {.name =3D "with-bootdevice", + .type =3D VSH_OT_STRING, + .help =3D N_("set boot device") + }, + {.name =3D "with-kernel", + .type =3D VSH_OT_STRING, + .flags =3D VSH_OFLAG_EMPTY_OK, + .help =3D N_("set boot kernel") + }, + {.name =3D "with-initrd", + .type =3D VSH_OT_STRING, + .flags =3D VSH_OFLAG_EMPTY_OK, + .help =3D N_("set boot initrd") + }, + {.name =3D "with-cmdline", + .type =3D VSH_OT_STRING, + .flags =3D VSH_OFLAG_EMPTY_OK, + .help =3D N_("set boot cmdline") + }, {.name =3D NULL} }; =20 @@ -4004,6 +4023,7 @@ cmdStartGetFDs(vshControl *ctl, return -1; } =20 + static bool cmdStart(vshControl *ctl, const vshCmd *cmd) { @@ -4016,6 +4036,10 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) int rc; size_t nfds =3D 0; int *fds =3D NULL; + const char *bootDeviceIdentifier =3D NULL; + const char *kernel =3D NULL; + const char *initrd =3D NULL; + const char *cmdline =3D NULL; =20 if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYNAME | VIRSH_BYUUID))) @@ -4038,9 +4062,68 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "force-boot")) flags |=3D VIR_DOMAIN_START_FORCE_BOOT; =20 + if (vshCommandOptStringReq(ctl, cmd, "with-bootdevice", + &bootDeviceIdentifier) < 0 || + vshCommandOptStringReq(ctl, cmd, "with-kernel", + &kernel) < 0 || + vshCommandOptStringReq(ctl, cmd, "with-initrd", + &initrd) < 0 || + vshCommandOptStringReq(ctl, cmd, "with-cmdline", + &cmdline) < 0) + goto cleanup; + + if (nfds && (bootDeviceIdentifier || kernel || initrd || cmdline)) { + vshError(ctl, + _("Passing file descriptors together with temporarily cha= nging" + " the boot configuration is currently not supported.")); + goto cleanup; + } + /* Prefer older API unless we have to pass extra parameters */ if (nfds) { rc =3D virDomainCreateWithFiles(dom, nfds, fds, flags); + } else if (bootDeviceIdentifier || kernel || initrd || cmdline) { + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; + int maxparams =3D 0; + + if (bootDeviceIdentifier) + virTypedParamsAddFromString(¶ms, + &nparams, + &maxparams, + VIR_DOMAIN_CREATE_PARM_DEVICE_IDEN= TIFIER, + VIR_TYPED_PARAM_STRING, + bootDeviceIdentifier); + + if (kernel) + virTypedParamsAddFromString(¶ms, + &nparams, + &maxparams, + VIR_DOMAIN_CREATE_PARM_KERNEL, + VIR_TYPED_PARAM_STRING, + kernel); + + if (initrd) + virTypedParamsAddFromString(¶ms, + &nparams, + &maxparams, + VIR_DOMAIN_CREATE_PARM_INITRD, + VIR_TYPED_PARAM_STRING, + initrd); + + if (cmdline) + virTypedParamsAddFromString(¶ms, + &nparams, + &maxparams, + VIR_DOMAIN_CREATE_PARM_CMDLINE, + VIR_TYPED_PARAM_STRING, + cmdline); + + rc =3D virDomainCreateWithParams(dom, + params, + nparams, + flags); + virTypedParamsFree(params, nparams); } else if (flags) { rc =3D virDomainCreateWithFlags(dom, flags); /* We can emulate force boot, even for older servers that @@ -4091,6 +4174,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) return ret; } =20 + /* * "save" command */ diff --git a/tools/virsh.pod b/tools/virsh.pod index 929958a9533c..54316aa33b97 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2655,6 +2655,8 @@ repeat the command. =20 =3Ditem B I [I<--console>] [I<--paused>] [I<--autodestroy>] [I<--bypass-cache>] [I<--force-boot>] [I<--pass-fds N,M= ,...>] +[I<--with-bootdevice DEVICE-IDENTIFIER>] [I<--with-kernel KERNEL>] +[I<--with-initrd INITRD>] [I<--with-cmdline CMDLINE>] =20 Start a (previously defined) inactive domain, either from the last B state, or via a fresh boot if no managedsave state is @@ -2668,6 +2670,18 @@ the restore will avoid the file system cache, althou= gh this may slow down the operation. If I<--force-boot> is specified, then any managedsave state is discarded and a fresh boot occurs. =20 +If the I<--with-bootdevice> option is used and supported by the driver +then the domain will start with the specified device overriding the +persistent defined boot order for this start only. Valid block devices +for this option are displayed using B. To specify a block +device the displayed I value has to be used. Valid network +devices are displayed using B. To specify a network device +the displayed I value has to be used. + +With I<--with-kernel>, I<--with-initrd>, and I<--with-cmdline> you can +specify the kernel, initrd, and cmdline to use for this start if the +used driver supports this. + If I<--pass-fds> is specified, the argument is a comma separated list of open file descriptors which should be pass on into the guest. The file descriptors will be re-numbered in the guest, starting from 3. This --=20 2.13.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list