From nobody Tue May 14 13:22:05 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1647696217307413.07589853619675; Sat, 19 Mar 2022 06:23:37 -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-387-e9cTjiyzMt6xDU-0gYpA4g-1; Sat, 19 Mar 2022 09:23:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD00C29AB443; Sat, 19 Mar 2022 13:23:30 +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 BBD311402400; Sat, 19 Mar 2022 13:23:27 +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 90CCD194035B; Sat, 19 Mar 2022 13:23:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E00391940341 for ; Sat, 19 Mar 2022 13:23:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BD259C202C6; Sat, 19 Mar 2022 13:23:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B970BC1D3AD for ; Sat, 19 Mar 2022 13:23:26 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E9CA8039D7 for ; Sat, 19 Mar 2022 13:23:26 +0000 (UTC) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-ruj2m7QsP6mRG9wvp7qGfQ-1; Sat, 19 Mar 2022 09:23:24 -0400 Received: by mail-pl1-f180.google.com with SMTP id n18so9199557plg.5 for ; Sat, 19 Mar 2022 06:23:24 -0700 (PDT) Received: from localhost.localdomain ([2409:4040:e25:6346:7900:a4ca:437f:4b67]) by smtp.gmail.com with ESMTPSA id lp4-20020a17090b4a8400b001bedba2df04sm11318159pjb.30.2022.03.19.06.23.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Mar 2022 06:23:22 -0700 (PDT) X-MC-Unique: e9cTjiyzMt6xDU-0gYpA4g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ruj2m7QsP6mRG9wvp7qGfQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SIo+maUV4x9DZttgWs9GOX8+KetfVR8ZDM/qroFb34w=; b=fxTKAwG5KFl7DwRYERZFq1awGntR3vUMkQlnW3QJNOnWqMrth2zsSDgO9PaZH7pSu9 3ibDTGUYr9EUMYQGJmqq64xUtzZUOQp7U2Ha4EVwB0jMX5CFqI45uAGMq/vCskrMSS0p 1ghP5xE+FNiMxBaQgO1h4ULz/0GAucarQEHWWRZ+zbbOHOGFO8I6CnOuT/oKU+BOtLeG ETnNIXq3CKNlwFSu6Zyj6TEauOMT4sY5jNTrU0QeXQ7o/IvFysrFCekz0qdprxeLc0zZ q1h3NjZ9VdetwQmGGETqoWAEBLCMpsqoPA5nx4bS4ic6z8hYOvpxVKy1MvYw+vYjaIiE Zglg== X-Gm-Message-State: AOAM530ymu+0WU9eWDwvgPXp2JIAzA0Z99ceUNY0UR9I7DNryGVOob01 T3ZbwmaqwbLH69pCu/o7Ve2p5bp5TVk= X-Google-Smtp-Source: ABdhPJwVYfqbVVCL6ZQhxhTk1zQsotz6od5W5crBJtL8Ywb8CDfUzeoG+7h3IYY/ZnNe29FyWnFQhQ== X-Received: by 2002:a17:902:d508:b0:154:2f99:a52e with SMTP id b8-20020a170902d50800b001542f99a52emr2422520plg.102.1647696203315; Sat, 19 Mar 2022 06:23:23 -0700 (PDT) From: Jamm02 X-Google-Original-From: Jamm02 To: libvir-list@redhat.com Subject: [PATCH] domain_conf: include checks against dom->os.type and dom->virtType Date: Sat, 19 Mar 2022 18:53:00 +0530 Message-Id: <20220319132300.86998-1-codeguy.moteen@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.85 on 10.11.54.8 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: , Cc: Jamm02 Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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-ZM-MESSAGEID: 1647696218096100001 Content-Type: text/plain; charset="utf-8" All the checks against dom->os.type and dom->virtType in virDomainInputDefParseXML shifted to virDomainInputDefValidate function Signed-off-by: Jamm02 --- src/conf/domain_conf.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e0dfc9e45f..b237fd9ab1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11837,6 +11837,55 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlo= pt, return NULL; } =20 +static virDomainInputDef * +virDomainInputDefValidate(const virDomainDef *dom, + xmlNodePtr node, + xmlXPathContextPtr ctxt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt) + virDomainInputDef *def; + g_autofree char *bus =3D NULL; + + def =3D g_new0(virDomainInputDef, 1); + + ctxt->node =3D node; + bus =3D virXMLPropString(node, "bus"); + + if (bus) { + if ((def->bus =3D virDomainInputBusTypeFromString(bus)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown input bus type '%s'"), bus); + goto error; + } + + } else { + if (dom->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { + if ((def->type =3D=3D VIR_DOMAIN_INPUT_TYPE_MOUSE || + def->type =3D=3D VIR_DOMAIN_INPUT_TYPE_KBD) && + (ARCH_IS_X86(dom->os.arch) || dom->os.arch =3D=3D VIR_ARCH= _NONE)) { + def->bus =3D VIR_DOMAIN_INPUT_BUS_PS2; + } else if (ARCH_IS_S390(dom->os.arch) || + def->type =3D=3D VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH)= { + def->bus =3D VIR_DOMAIN_INPUT_BUS_VIRTIO; + } else if (def->type =3D=3D VIR_DOMAIN_INPUT_TYPE_EVDEV) { + def->bus =3D VIR_DOMAIN_INPUT_BUS_NONE; + } else { + def->bus =3D VIR_DOMAIN_INPUT_BUS_USB; + } + } else if (dom->os.type =3D=3D VIR_DOMAIN_OSTYPE_XEN || + dom->os.type =3D=3D VIR_DOMAIN_OSTYPE_XENPVH) { + def->bus =3D VIR_DOMAIN_INPUT_BUS_XEN; + } else { + if ((dom->virtType =3D=3D VIR_DOMAIN_VIRT_VZ || + dom->virtType =3D=3D VIR_DOMAIN_VIRT_PARALLELS)) + def->bus =3D VIR_DOMAIN_INPUT_BUS_PARALLELS; + } + } + + error: + virDomainInputDefFree(def); + return NULL; +} /* Parse the XML definition for an input device */ static virDomainInputDef * virDomainInputDefParseXML(virDomainXMLOption *xmlopt, --=20 2.35.1