From nobody Mon Apr 29 06:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1612673811; cv=none; d=zohomail.com; s=zohoarc; b=OfgDosp4oJ0KFGMNDSNpwvvidA/jRHXxQWSlDkZKhO6OEhcnUwzCXtKLotJSF78o/orrtuVQ1w56gVPsBvWd/8WkcZZygQXj9OWl7QFALvMxbBIEMKo0dj17uTZq4oeI+xS2Cab3vrWosZJ7Vw2G4NOSpNmtv2rzZL2lltcEIUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612673811; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=uT8l9TUnHdicmhyS0XIxdin3ZaKbROs9OLTWUlUanZY=; b=iGF6Zt2V2DKRKBLyCEjuFAVupv7c0Tehg9jYuKPi2TfZQ3mMRyXhIjmA0LCxss5Qt7Z/XzEGOK4DnxDEqnbSGZavHMdr+Th1ATYhxobAMTtoZ3ayJAMJZgfiFsuNvwAlZlJASu2azJLMaMPRbZmcmzfOgmQg3RtBSp1FkU4q5us= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612673811275186.9244263546608; Sat, 6 Feb 2021 20:56:51 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-3wA0YvP1PkiV07fJ4aUgTA-1; Sat, 06 Feb 2021 23:56:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E207801962; Sun, 7 Feb 2021 04:56:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DE2210016F7; Sun, 7 Feb 2021 04:56:38 +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 DC2834E58E; Sun, 7 Feb 2021 04:56:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1174uVsS014828 for ; Sat, 6 Feb 2021 23:56:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id D2FEC2026D11; Sun, 7 Feb 2021 04:56:31 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE0512026D46 for ; Sun, 7 Feb 2021 04:56:29 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4001C101A53A for ; Sun, 7 Feb 2021 04:56:29 +0000 (UTC) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-541-XPrtdFCNNi6ySt4WGwTvYw-1; Sat, 06 Feb 2021 23:56:27 -0500 Received: by mail-lf1-f52.google.com with SMTP id m22so17056537lfg.5 for ; Sat, 06 Feb 2021 20:56:26 -0800 (PST) Received: from kloomba.my.domain ([5.227.218.122]) by smtp.gmail.com with ESMTPSA id k19sm1558547lfm.204.2021.02.06.20.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Feb 2021 20:56:24 -0800 (PST) X-MC-Unique: 3wA0YvP1PkiV07fJ4aUgTA-1 X-MC-Unique: XPrtdFCNNi6ySt4WGwTvYw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uT8l9TUnHdicmhyS0XIxdin3ZaKbROs9OLTWUlUanZY=; b=D5kt3hknwLE4sGaBWaiUvI/mz77RguKdQczlTzAZBaBLum0UrsTe3AkFu1LvaGXCJw ccPHS5fi1LobG9FyjY+hjv6/QTyACUSQDYJm2pQAJTQXeFYHT+hl2QsmTH9PK2/RwmJN nyI3UcrNwdMKcTkJqklHKnxbUX6HtXvu8qVh8MXpAtZZVYjySVD6D6N0w2HEnJErsXRY Vt1zDsIOvMDRYkyrrPN5xT86aPdEplhkUOeVhL6iVVO9frOiXKA8BIMo8tsnULDB8QOn yNh4k6Keli4BmiegUYQtwfCQZprGSbMleWk0cUt+RnV+rp7gQXW6xzY8v0KrT+aR0K7N viAw== X-Gm-Message-State: AOAM531wBblaI9zfEU0E33QCwIcGwg1de3jb51vLnKACvuhaTZM8HMfh NJPdRJXqHzRra7qj1NECiUVzxGNfUBbGGN8w X-Google-Smtp-Source: ABdhPJxBaGJFLQ+JD3di68Aw+qpeMUIvQD4XziWAHOU949CBYYl/ZtL+ML+kwxIk0bv6rhMpxp/AOg== X-Received: by 2002:a05:6512:782:: with SMTP id x2mr7320095lfr.633.1612673785287; Sat, 06 Feb 2021 20:56:25 -0800 (PST) From: Roman Bogorodskiy To: libvir-list@redhat.com Subject: [PATCH] bhyve: auto allocate nmdm console paths Date: Sun, 7 Feb 2021 08:56:17 +0400 Message-Id: <20210207045617.25589-1-bogorodskiy@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Roman Bogorodskiy 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 Content-Type: text/plain; charset="utf-8" Currently, nmdm console device requires user to specify master and slave path attributes (such as /dev/nmdm0A and /dev/nmdm0B respectively). However, making user find a non-occupied device name might be not convenient, especially for the remote connections. Update the logic to make these attributes optional. In case if not specified, use /dev/nmdm$UUID[AB], where $UUID is a domain's UUID. With this schema it's unlikely nmdm device will clash with other domains or even other non-bhyve nmdm devices. Signed-off-by: Roman Bogorodskiy Reviewed-by: J=C3=A1n Tomko --- src/bhyve/bhyve_domain.c | 14 ++++++ src/conf/domain_validate.c | 15 +++---- ...gv-console-master-slave-not-specified.args | 11 +++++ ...-console-master-slave-not-specified.ldargs | 3 ++ ...rgv-console-master-slave-not-specified.xml | 24 ++++++++++ tests/bhyvexml2argvtest.c | 1 + ...out-console-master-slave-not-specified.xml | 44 +++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 8 files changed, 104 insertions(+), 9 deletions(-) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console-master-sl= ave-not-specified.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console-master-sl= ave-not-specified.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-console-master-sl= ave-not-specified.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console-maste= r-slave-not-specified.xml diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 1d99ba6c96..8fbc554a0a 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -170,6 +170,20 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, dev->data.video->type =3D VIR_DOMAIN_VIDEO_TYPE_GOP; } =20 + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_NMDM) { + virDomainChrDefPtr chr =3D dev->data.chr; + + if (!chr->source->data.nmdm.master) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + virUUIDFormat(def->uuid, uuidstr); + + chr->source->data.nmdm.master =3D g_strdup_printf("/dev/nmdm%s= A", uuidstr); + chr->source->data.nmdm.slave =3D g_strdup_printf("/dev/nmdm%sB= ", uuidstr); + } + } + return 0; } =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 222a9386f6..de3661fa3d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -579,17 +579,14 @@ virDomainChrSourceDefValidate(const virDomainChrSourc= eDef *src_def, break; =20 case VIR_DOMAIN_CHR_TYPE_NMDM: - if (!src_def->data.nmdm.master) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing master path attribute for nmdm devic= e")); - return -1; + if ((src_def->data.nmdm.master && !src_def->data.nmdm.slave) || + (!src_def->data.nmdm.master && src_def->data.nmdm.slave)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Should define both master and slave " + "path attributes for nmdm device")); + return -1; } =20 - if (!src_def->data.nmdm.slave) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing slave path attribute for nmdm device= ")); - return -1; - } break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slave-not= -specified.args b/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slav= e-not-specified.args new file mode 100644 index 0000000000..b24918e7eb --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slave-not-specif= ied.args @@ -0,0 +1,11 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 1:0,lpc \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=3D52:54:00:b1:42:eb \ +-l com1,/dev/nmdmdf3be7e7-a104-11e3-aeb0-50e5492bd3dcA bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slave-not= -specified.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-sl= ave-not-specified.ldargs new file mode 100644 index 0000000000..32538b558e --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slave-not-specif= ied.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slave-not= -specified.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slave= -not-specified.xml new file mode 100644 index 0000000000..6e198a49d1 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console-master-slave-not-specif= ied.xml @@ -0,0 +1,24 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + +
+ + + + + +
+ + + + diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index be816e554f..197334f9c4 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -177,6 +177,7 @@ mymain(void) DO_TEST("macaddr"); DO_TEST("serial"); DO_TEST("console"); + DO_TEST("console-master-slave-not-specified"); DO_TEST("grub-defaults"); DO_TEST("grub-bootorder"); DO_TEST("grub-bootorder2"); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console-master-slave= -not-specified.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console-mast= er-slave-not-specified.xml new file mode 100644 index 0000000000..6a2f58a947 --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console-master-slave-not-sp= ecified.xml @@ -0,0 +1,44 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + + + + +
+ + + +
+ + +
+ + + + + +
+ + + + + + + + + + + diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index eb9b108704..428f1b47bb 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -88,6 +88,7 @@ mymain(void) DO_TEST_DIFFERENT("bhyveload-bootorder4"); DO_TEST_DIFFERENT("bhyveload-explicitargs"); DO_TEST_DIFFERENT("console"); + DO_TEST_DIFFERENT("console-master-slave-not-specified"); DO_TEST_DIFFERENT("custom-loader"); DO_TEST_DIFFERENT("disk-cdrom"); DO_TEST_DIFFERENT("disk-cdrom-grub"); --=20 2.30.0