From nobody Thu May 2 06:52:50 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560519269; cv=none; d=zoho.com; s=zohoarc; b=KGGsiEQFS17WUmIbY5e9RKl9dmj/knQYgVV8AQYLd8paCAyelXNWt/RDS1RH/R7iqdI3xgG4MqAglLiHW62ilt2isw4KD1AWWE+HujkWbKqopGUYa/zs83UiQICHZOYXbHVFjyVMLwXknGB4MyyPHUeyyMQyq2tMkRCiquV1xds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560519269; 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:ARC-Authentication-Results; bh=DavRJjhiPVoOht6Dcuw52E0FRN12RLhi1hGCYTTdVbI=; b=ng2/XpUbraVG9ElbQojY85Y0eIiBB0WWOgtwpMgrQwOecamQa+Xu5U7DF2Azb+n2m/SfYJgPI6a0CEv3dCC2rQUPd0NiHhPqgU2DuzD3raCq+k2ofi+yNngUbaiykcI7tA58GigNydK4I1Bt6dBMUaq1OLfj2Ud9EtxLejjQ260= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560519269012364.95619455830786; Fri, 14 Jun 2019 06:34:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4301A3092657; Fri, 14 Jun 2019 13:34:12 +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 1B0435FCB4; Fri, 14 Jun 2019 13:34:09 +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 C9DB5206D2; Fri, 14 Jun 2019 13:34:08 +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 x5EDUWJ8019709 for ; Fri, 14 Jun 2019 09:30:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id E79542CE56; Fri, 14 Jun 2019 13:30:31 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7385F1753B for ; Fri, 14 Jun 2019 13:30:31 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 14 Jun 2019 15:30:23 +0200 Message-Id: <1cb36b76b6f1443072ff01fffe20494e44581a88.1560518789.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 1/5] qemu: driver: Drop support for qemu-attach 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 14 Jun 2019 13:34:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Attaching to modern qemu will not work with all this code and attempting to ressurect it would be mostly pointless. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/check-aclrules.pl | 1 + src/qemu/qemu_driver.c | 87 +++--------------------------------------- 2 files changed, 6 insertions(+), 82 deletions(-) diff --git a/src/check-aclrules.pl b/src/check-aclrules.pl index 23872cda98..be618f6c9f 100755 --- a/src/check-aclrules.pl +++ b/src/check-aclrules.pl @@ -61,6 +61,7 @@ my %whitelist =3D ( "interfaceClose" =3D> 1, "connectURIProbe" =3D> 1, "localOnly" =3D> 1, + "domainQemuAttach" =3D> 1, ); # XXX this vzDomainMigrateConfirm3Params looks diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f623eaa422..bb6ba97c7a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16799,92 +16799,15 @@ static int qemuDomainQemuMonitorCommand(virDomain= Ptr domain, const char *cmd, } -static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn, - unsigned int pid_value, +static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn ATTRIBUTE_UNUS= ED, + unsigned int pid_value ATTRIBUTE_= UNUSED, unsigned int flags) { - virQEMUDriverPtr driver =3D conn->privateData; - virDomainObjPtr vm =3D NULL; - virDomainDefPtr def =3D NULL; - virDomainPtr dom =3D NULL; - virDomainChrSourceDefPtr monConfig =3D NULL; - bool monJSON =3D false; - pid_t pid =3D pid_value; - char *pidfile =3D NULL; - virQEMUCapsPtr qemuCaps =3D NULL; - virCapsPtr caps =3D NULL; - virCheckFlags(0, NULL); - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - - if (!(def =3D qemuParseCommandLinePid(driver->qemuCapsCache, - caps, driver->xmlopt, pid, - &pidfile, &monConfig, &monJSON))) - goto cleanup; - - if (virDomainQemuAttachEnsureACL(conn, def) < 0) - goto cleanup; - - if (!monConfig) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("No monitor connection for pid %u"), pid_value); - goto cleanup; - } - if (monConfig->type !=3D VIR_DOMAIN_CHR_TYPE_UNIX) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Cannot connect to monitor connection of type '%s= ' " - "for pid %u"), - virDomainChrTypeToString(monConfig->type), - pid_value); - goto cleanup; - } - - if (!(def->name) && - virAsprintf(&def->name, "attach-pid-%u", pid_value) < 0) - goto cleanup; - - if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, - def->emulator))) - goto cleanup; - - if (qemuAssignDeviceAliases(def, qemuCaps) < 0) - goto cleanup; - - if (!(vm =3D virDomainObjListAdd(driver->domains, def, - driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) - goto cleanup; - - def =3D NULL; - - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) { - qemuDomainRemoveInactive(driver, vm); - goto cleanup; - } - - if (qemuProcessAttach(conn, driver, vm, pid, - pidfile, monConfig, monJSON) < 0) { - qemuDomainRemoveInactive(driver, vm); - qemuDomainObjEndJob(driver, vm); - goto cleanup; - } - - dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); - - qemuDomainObjEndJob(driver, vm); - - cleanup: - virDomainDefFree(def); - virObjectUnref(monConfig); - virDomainObjEndAPI(&vm); - VIR_FREE(pidfile); - virObjectUnref(caps); - virObjectUnref(qemuCaps); - return dom; + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("attaching to a non-libvirt qemu process is no longer= supported")); + return NULL; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:52:50 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560519116; cv=none; d=zoho.com; s=zohoarc; b=Fj8zCpkC/Tip5/m6iez8SQV87/SZCCOpk7yPCiD3ujfJyVF5UyvWFlvtUc8LviblR0bvR4+a2w4xJDq9D8AFpX9QEdnM5vYxljYBA9JaLNei57iogkV2G6HKZZqqFfidMUNcw4/PHxUp1rtfRctG5HnLpWXAyB9tl3q6TsGvpyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560519116; 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:ARC-Authentication-Results; bh=3p5PYuYfxZritpWDOz/ceLHdFz08Pr0ABxORG8iHa9E=; b=nr7s5Dy9wecAQ+SuhrpZkln5inpmHdOIb6VulyrzcZlbOQcBKcPLdea5tipVD8ZlrprecFjG94IY1dDyVH+U6d52Hei0Tz83cHjjyvzUcmhZ8VQ8q9abC1sAO2lBGr1QO7wyT9bh0sn3jI0lrQamT8oeF2etr/JX2D2K9Vd18lU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560519116547786.568387629941; Fri, 14 Jun 2019 06:31:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56BBDA3B79; Fri, 14 Jun 2019 13:31:43 +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 3E90019C58; Fri, 14 Jun 2019 13:31:37 +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 847BD1806B0F; Fri, 14 Jun 2019 13:31:32 +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 x5EDUWov019736 for ; Fri, 14 Jun 2019 09:30:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id B50331753B; Fri, 14 Jun 2019 13:30:32 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FC3E2CE56 for ; Fri, 14 Jun 2019 13:30:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 14 Jun 2019 15:30:24 +0200 Message-Id: <4b97209356cd3f4b1fcdbef3a38ff2e075b9252b.1560518789.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 2/5] qemu: parse: Drop qemuParseCommandLinePid and friends 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: , 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 14 Jun 2019 13:31:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that we no longer support attaching to a live non-libvirt qemu we can drop the backend functions as well. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_parse_command.c | 92 ----------------------------------- src/qemu/qemu_parse_command.h | 7 --- 2 files changed, 99 deletions(-) diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index fc3f70fcde..b522882c78 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -2767,95 +2767,3 @@ virDomainDefPtr qemuParseCommandLineString(virFileCa= chePtr capsCache, return def; } - - -static int qemuParseProcFileStrings(int pid_value, - const char *name, - char ***list) -{ - char *path =3D NULL; - int ret =3D -1; - char *data =3D NULL; - ssize_t len; - char *tmp; - size_t nstr =3D 0; - char **str =3D NULL; - - if (virAsprintf(&path, "/proc/%d/%s", pid_value, name) < 0) - goto cleanup; - - if ((len =3D virFileReadAll(path, 1024*128, &data)) < 0) - goto cleanup; - - tmp =3D data; - while (tmp < (data + len)) { - if (VIR_EXPAND_N(str, nstr, 1) < 0) - goto cleanup; - - if (VIR_STRDUP(str[nstr-1], tmp) < 0) - goto cleanup; - /* Skip arg */ - tmp +=3D strlen(tmp); - /* Skip \0 separator */ - tmp++; - } - - if (VIR_EXPAND_N(str, nstr, 1) < 0) - goto cleanup; - - str[nstr-1] =3D NULL; - - ret =3D nstr-1; - *list =3D str; - - cleanup: - if (ret < 0) - virStringListFree(str); - VIR_FREE(data); - VIR_FREE(path); - return ret; -} - -virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - pid_t pid, - char **pidfile, - virDomainChrSourceDefPtr *monConfi= g, - bool *monJSON) -{ - virDomainDefPtr def =3D NULL; - char **progargv =3D NULL; - char **progenv =3D NULL; - char *exepath =3D NULL; - char *emulator; - - /* The parser requires /proc/pid, which only exists on platforms - * like Linux where pid_t fits in int. */ - if ((int)pid !=3D pid || - qemuParseProcFileStrings(pid, "cmdline", &progargv) < 0 || - qemuParseProcFileStrings(pid, "environ", &progenv) < 0) - goto cleanup; - - if (!(def =3D qemuParseCommandLine(capsCache, caps, xmlopt, progenv, p= rogargv, - pidfile, monConfig, monJSON))) - goto cleanup; - - if (virAsprintf(&exepath, "/proc/%d/exe", (int)pid) < 0) - goto cleanup; - - if (virFileResolveLink(exepath, &emulator) < 0) { - virReportSystemError(errno, - _("Unable to resolve %s for pid %u"), - exepath, (int)pid); - goto cleanup; - } - VIR_FREE(def->emulator); - def->emulator =3D emulator; - - cleanup: - VIR_FREE(exepath); - virStringListFree(progargv); - virStringListFree(progenv); - return def; -} diff --git a/src/qemu/qemu_parse_command.h b/src/qemu/qemu_parse_command.h index 5eeb344c60..4dbb08fd59 100644 --- a/src/qemu/qemu_parse_command.h +++ b/src/qemu/qemu_parse_command.h @@ -37,13 +37,6 @@ virDomainDefPtr qemuParseCommandLineString(virFileCacheP= tr capsCache, char **pidfile, virDomainChrSourceDefPtr *monCo= nfig, bool *monJSON); -virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - pid_t pid, - char **pidfile, - virDomainChrSourceDefPtr *monConfi= g, - bool *monJSON); void qemuParseKeywordsFree(int nkeywords, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:52:50 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560519143; cv=none; d=zoho.com; s=zohoarc; b=RU2H6NwTSHQCT8CBCBh9FIQDwcoTNSOAqVf7bM86y4cS+dY10yvAK1pKv/ht1t6FMcI2Hy0HnruIOuAgxgA10GFGtJ6yjgndvvBBtf8HZ6zzksr/063U/ven7eJt9hT+qc6MNxJwrXUa/yTbNfu/sPEEhE0mia1DM+xdZFPNPyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560519143; 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:ARC-Authentication-Results; bh=Ty9spcOuUkbKBzkUHSKFl+ERfVkEHnWvK9WIjrWGE+E=; b=FsNPjZpUoGQugiRcRVPDoCoFqVDjfbvslbUwLy6DJGSZZpNUc9veHl8Zd6rTOFkPtvzycdYH+03T9jmAeiO5Lwnrp1ysObQXHuEmVYmZgCkLlwBdTRuDpMgsZfUOOwexsRKZn1OpBpDmAxOmhjcCJgKfHl/G0LywS8G7bgq/H9w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560519143913734.4281478838103; Fri, 14 Jun 2019 06:32:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEC1D2F8BF4; Fri, 14 Jun 2019 13:32:13 +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 5B99B19700; Fri, 14 Jun 2019 13:32:08 +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 1CAEC1806B12; Fri, 14 Jun 2019 13:32:06 +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 x5EDUXfY019762 for ; Fri, 14 Jun 2019 09:30:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 816962CE56; Fri, 14 Jun 2019 13:30:33 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1CA1753B for ; Fri, 14 Jun 2019 13:30:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 14 Jun 2019 15:30:25 +0200 Message-Id: <27f45340fc315f8f1a9ee42b9ad584578b1493bd.1560518789.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 3/5] qemu: driver: Remove support for native->XML conversion 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: , 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 14 Jun 2019 13:32:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This code is really neglected and does not at all work reliably. It can't even be used for converting our own commandline back. Since this was mostly useful for aiding migration from manually run qemu to libvirt and will not work for this puspose in many cases it's not worth having in my opinion. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bb6ba97c7a..7279b20d2e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7319,44 +7319,18 @@ static char static char *qemuConnectDomainXMLFromNative(virConnectPtr conn, - const char *format, - const char *config, + const char *format ATTRIBUTE_U= NUSED, + const char *config ATTRIBUTE_U= NUSED, unsigned int flags) { - virQEMUDriverPtr driver =3D conn->privateData; - virDomainDefPtr def =3D NULL; - char *xml =3D NULL; - virCapsPtr caps =3D NULL; - virCheckFlags(0, NULL); if (virConnectDomainXMLFromNativeEnsureACL(conn) < 0) - goto cleanup; - - if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) { - virReportError(VIR_ERR_INVALID_ARG, - _("unsupported config type %s"), format); - goto cleanup; - } - - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - - def =3D qemuParseCommandLineString(driver->qemuCapsCache, - caps, driver->xmlopt, config, - NULL, NULL, NULL); - if (!def) - goto cleanup; - - if (!def->name && VIR_STRDUP(def->name, "unnamed") < 0) - goto cleanup; - - xml =3D qemuDomainDefFormatXML(driver, def, VIR_DOMAIN_XML_INACTIVE); + return NULL; - cleanup: - virDomainDefFree(def); - virObjectUnref(caps); - return xml; + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("qemu driver no longer supports native to XML convers= ion")); + return NULL; } static char *qemuConnectDomainXMLToNative(virConnectPtr conn, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:52:50 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560519178; cv=none; d=zoho.com; s=zohoarc; b=juGkNXdyXtb0lmp9u1rwtMrmUsYHBweMNZ5tFphGlnBz0QFKE676IqDvKfYURkOGEF8J66cueDEfXEEWlkqnTgcF1VvfwiFaBP2JlaHLGymJDFivyXTAKJT5U+Yji1d2MlFUTSRdxhv22VMw7/0diKhx3uebxTAG4vOLRsSYds8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560519178; 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:ARC-Authentication-Results; bh=aJ6cOmLjRHlKmlQ/fPM479kwnecZTS2k2NzuOTVPb6c=; b=lw00usqqEM9ITLRXOU12rz5QUpMGlpVW4Cvn5OQlCp6+vbn8gFrPOaOdYeBD0q/eu9igpjr+zlVjxPFo7fcWSL6enc6t9jszMcAUOZeSbyKQPIhtVWMpHaoXE6nu8hFijex0Vqs7g5tthC13KFyH9ctfnKc/Mq+DUNF/FOmqk+k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560519178860200.37743582978692; Fri, 14 Jun 2019 06:32:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 560DA309B159; Fri, 14 Jun 2019 13:32:40 +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 2684867290; Fri, 14 Jun 2019 13:32:35 +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 DCD7F1806B18; Fri, 14 Jun 2019 13:32:32 +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 x5EDUYmq019797 for ; Fri, 14 Jun 2019 09:30:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7367C2CE56; Fri, 14 Jun 2019 13:30:34 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD77D1753B for ; Fri, 14 Jun 2019 13:30:33 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 14 Jun 2019 15:30:26 +0200 Message-Id: <02e5e5a0e5503512ac23f502dba1bb5c88d37881.1560518789.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 4/5] tests: Drop qemuargv2xmltest 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 14 Jun 2019 13:32:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that we no longer use that functionality we can also drop the tests. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/Makefile.am | 11 +- tests/qemuargv2xmldata/boot-cdrom.args | 22 -- tests/qemuargv2xmldata/boot-cdrom.xml | 35 -- tests/qemuargv2xmldata/boot-floppy.args | 23 -- tests/qemuargv2xmldata/boot-floppy.xml | 41 --- tests/qemuargv2xmldata/boot-network.args | 22 -- tests/qemuargv2xmldata/boot-network.xml | 34 -- tests/qemuargv2xmldata/clock-localtime.args | 23 -- tests/qemuargv2xmldata/clock-localtime.xml | 34 -- tests/qemuargv2xmldata/clock-utc.args | 22 -- tests/qemuargv2xmldata/clock-utc.xml | 34 -- tests/qemuargv2xmldata/console-compat.args | 22 -- tests/qemuargv2xmldata/console-compat.xml | 42 --- tests/qemuargv2xmldata/disk-cdrom-empty.args | 23 -- tests/qemuargv2xmldata/disk-cdrom-empty.xml | 40 --- tests/qemuargv2xmldata/disk-cdrom.args | 23 -- tests/qemuargv2xmldata/disk-cdrom.xml | 41 --- .../disk-drive-boot-cdrom.args | 23 -- .../disk-drive-boot-cdrom.xml | 41 --- .../disk-drive-boot-disk.args | 23 -- .../qemuargv2xmldata/disk-drive-boot-disk.xml | 41 --- .../disk-drive-cache-directsync.args | 24 -- .../disk-drive-cache-directsync.xml | 41 --- .../disk-drive-cache-unsafe.args | 24 -- .../disk-drive-cache-unsafe.xml | 41 --- .../disk-drive-cache-v2-none.args | 23 -- .../disk-drive-cache-v2-none.xml | 41 --- .../disk-drive-cache-v2-wb.args | 24 -- .../disk-drive-cache-v2-wb.xml | 41 --- .../disk-drive-cache-v2-wt.args | 24 -- .../disk-drive-cache-v2-wt.xml | 41 --- .../disk-drive-error-policy-enospace.args | 24 -- .../disk-drive-error-policy-enospace.xml | 41 --- .../disk-drive-error-policy-stop.args | 24 -- .../disk-drive-error-policy-stop.xml | 41 --- ...sk-drive-error-policy-wreport-rignore.args | 24 -- ...isk-drive-error-policy-wreport-rignore.xml | 41 --- .../qemuargv2xmldata/disk-drive-fmt-qcow.args | 23 -- .../qemuargv2xmldata/disk-drive-fmt-qcow.xml | 41 --- .../disk-drive-network-gluster.args | 25 -- .../disk-drive-network-gluster.xml | 41 --- .../disk-drive-network-iscsi-auth.args | 25 -- .../disk-drive-network-iscsi-auth.xml | 44 --- .../disk-drive-network-iscsi.args | 25 -- .../disk-drive-network-iscsi.xml | 41 --- .../disk-drive-network-nbd-export.args | 23 -- .../disk-drive-network-nbd-export.xml | 42 --- .../disk-drive-network-nbd-ipv6-export.args | 23 -- .../disk-drive-network-nbd-ipv6-export.xml | 42 --- .../disk-drive-network-nbd-ipv6.args | 23 -- .../disk-drive-network-nbd-ipv6.xml | 42 --- .../disk-drive-network-nbd-unix.args | 23 -- .../disk-drive-network-nbd-unix.xml | 42 --- .../disk-drive-network-nbd.args | 23 -- .../disk-drive-network-nbd.xml | 42 --- .../disk-drive-network-rbd-auth.args | 26 -- .../disk-drive-network-rbd-auth.xml | 47 --- .../disk-drive-network-rbd-ceph-env.args | 25 -- .../disk-drive-network-rbd-ceph-env.xml | 44 --- .../disk-drive-network-rbd-ipv6.args | 25 -- .../disk-drive-network-rbd-ipv6.xml | 45 --- .../disk-drive-network-rbd.args | 29 -- .../disk-drive-network-rbd.xml | 72 ---- .../disk-drive-network-sheepdog.args | 23 -- .../disk-drive-network-sheepdog.xml | 42 --- tests/qemuargv2xmldata/disk-floppy.args | 24 -- tests/qemuargv2xmldata/disk-floppy.xml | 47 --- tests/qemuargv2xmldata/disk-many.args | 25 -- tests/qemuargv2xmldata/disk-many.xml | 52 --- tests/qemuargv2xmldata/disk-usb.args | 23 -- tests/qemuargv2xmldata/disk-usb.xml | 39 --- tests/qemuargv2xmldata/disk-virtio.args | 25 -- tests/qemuargv2xmldata/disk-virtio.xml | 53 --- .../graphics-sdl-fullscreen.args | 25 -- .../graphics-sdl-fullscreen.xml | 39 --- tests/qemuargv2xmldata/graphics-sdl.args | 24 -- tests/qemuargv2xmldata/graphics-sdl.xml | 39 --- .../qemuargv2xmldata/graphics-vnc-policy.args | 23 -- .../qemuargv2xmldata/graphics-vnc-policy.xml | 41 --- tests/qemuargv2xmldata/graphics-vnc-sasl.args | 24 -- tests/qemuargv2xmldata/graphics-vnc-sasl.xml | 41 --- .../qemuargv2xmldata/graphics-vnc-socket.args | 23 -- .../qemuargv2xmldata/graphics-vnc-socket.xml | 41 --- tests/qemuargv2xmldata/graphics-vnc-tls.args | 24 -- tests/qemuargv2xmldata/graphics-vnc-tls.xml | 41 --- .../graphics-vnc-websocket.args | 22 -- .../graphics-vnc-websocket.xml | 32 -- tests/qemuargv2xmldata/graphics-vnc.args | 23 -- tests/qemuargv2xmldata/graphics-vnc.xml | 41 --- .../qemuargv2xmldata/hostdev-pci-address.args | 23 -- .../qemuargv2xmldata/hostdev-pci-address.xml | 40 --- .../qemuargv2xmldata/hostdev-usb-address.args | 23 -- .../qemuargv2xmldata/hostdev-usb-address.xml | 39 --- tests/qemuargv2xmldata/hyperv-panic.args | 21 -- tests/qemuargv2xmldata/hyperv-panic.xml | 29 -- tests/qemuargv2xmldata/hyperv.args | 21 -- tests/qemuargv2xmldata/hyperv.xml | 33 -- tests/qemuargv2xmldata/input-usbmouse.args | 23 -- tests/qemuargv2xmldata/input-usbmouse.xml | 35 -- tests/qemuargv2xmldata/input-usbtablet.args | 23 -- tests/qemuargv2xmldata/input-usbtablet.xml | 35 -- tests/qemuargv2xmldata/kvm-features.args | 21 -- tests/qemuargv2xmldata/kvm-features.xml | 31 -- tests/qemuargv2xmldata/kvmclock.args | 22 -- tests/qemuargv2xmldata/kvmclock.xml | 30 -- .../machine-aeskeywrap-off-argv.args | 18 - .../machine-aeskeywrap-off-argv.xml | 23 -- .../machine-aeskeywrap-on-argv.args | 18 - .../machine-aeskeywrap-on-argv.xml | 23 -- tests/qemuargv2xmldata/machine-core-off.args | 22 -- tests/qemuargv2xmldata/machine-core-off.xml | 34 -- tests/qemuargv2xmldata/machine-core-on.args | 22 -- tests/qemuargv2xmldata/machine-core-on.xml | 34 -- .../machine-deakeywrap-off-argv.args | 18 - .../machine-deakeywrap-off-argv.xml | 23 -- .../machine-deakeywrap-on-argv.args | 18 - .../machine-deakeywrap-on-argv.xml | 23 -- .../machine-keywrap-none-argv.args | 18 - .../machine-keywrap-none-argv.xml | 20 -- .../qemuargv2xmldata/mem-scale-maxmemory.args | 22 -- .../qemuargv2xmldata/mem-scale-maxmemory.xml | 38 --- tests/qemuargv2xmldata/mem-scale.args | 22 -- tests/qemuargv2xmldata/mem-scale.xml | 37 -- tests/qemuargv2xmldata/migrate.args | 23 -- tests/qemuargv2xmldata/migrate.xml | 34 -- tests/qemuargv2xmldata/misc-acpi.args | 21 -- tests/qemuargv2xmldata/misc-acpi.xml | 37 -- tests/qemuargv2xmldata/misc-disable-s3.args | 23 -- tests/qemuargv2xmldata/misc-disable-s3.xml | 37 -- .../misc-disable-suspends.args | 24 -- .../misc-disable-suspends.xml | 38 --- tests/qemuargv2xmldata/misc-enable-s4.args | 23 -- tests/qemuargv2xmldata/misc-enable-s4.xml | 37 -- tests/qemuargv2xmldata/misc-no-reboot.args | 23 -- tests/qemuargv2xmldata/misc-no-reboot.xml | 34 -- tests/qemuargv2xmldata/misc-uuid.args | 21 -- tests/qemuargv2xmldata/misc-uuid.xml | 37 -- tests/qemuargv2xmldata/net-eth-ifname.args | 23 -- tests/qemuargv2xmldata/net-eth-ifname.xml | 41 --- tests/qemuargv2xmldata/net-eth.args | 23 -- tests/qemuargv2xmldata/net-eth.xml | 40 --- tests/qemuargv2xmldata/net-user.args | 23 -- tests/qemuargv2xmldata/net-user.xml | 39 --- tests/qemuargv2xmldata/net-virtio.args | 23 -- tests/qemuargv2xmldata/net-virtio.xml | 39 --- .../nographics-vga-display.args | 23 -- .../nographics-vga-display.xml | 34 -- tests/qemuargv2xmldata/nographics-vga.args | 23 -- tests/qemuargv2xmldata/nographics-vga.xml | 34 -- tests/qemuargv2xmldata/nomachine-ppc64.args | 11 - tests/qemuargv2xmldata/nomachine-ppc64.xml | 50 --- tests/qemuargv2xmldata/nomachine-x86_64.args | 11 - tests/qemuargv2xmldata/nomachine-x86_64.xml | 49 --- tests/qemuargv2xmldata/nosharepages.args | 22 -- tests/qemuargv2xmldata/nosharepages.xml | 37 -- tests/qemuargv2xmldata/parallel-tcp.args | 22 -- tests/qemuargv2xmldata/parallel-tcp.xml | 39 --- tests/qemuargv2xmldata/pseries-disk.args | 18 - tests/qemuargv2xmldata/pseries-disk.xml | 50 --- tests/qemuargv2xmldata/pseries-nvram.args | 22 -- tests/qemuargv2xmldata/pseries-nvram.xml | 30 -- tests/qemuargv2xmldata/qemu-ns-no-env.args | 23 -- tests/qemuargv2xmldata/qemu-ns-no-env.xml | 38 --- .../reboot-timeout-disabled.args | 21 -- .../reboot-timeout-disabled.xml | 26 -- .../reboot-timeout-enabled.args | 21 -- .../reboot-timeout-enabled.xml | 26 -- tests/qemuargv2xmldata/restore-v2.args | 23 -- tests/qemuargv2xmldata/restore-v2.xml | 34 -- tests/qemuargv2xmldata/serial-dev.args | 22 -- tests/qemuargv2xmldata/serial-dev.xml | 44 --- tests/qemuargv2xmldata/serial-file.args | 22 -- tests/qemuargv2xmldata/serial-file.xml | 44 --- tests/qemuargv2xmldata/serial-many.args | 23 -- tests/qemuargv2xmldata/serial-many.xml | 48 --- tests/qemuargv2xmldata/serial-pty.args | 22 -- tests/qemuargv2xmldata/serial-pty.xml | 42 --- tests/qemuargv2xmldata/serial-tcp-telnet.args | 22 -- tests/qemuargv2xmldata/serial-tcp-telnet.xml | 46 --- tests/qemuargv2xmldata/serial-tcp.args | 22 -- tests/qemuargv2xmldata/serial-tcp.xml | 46 --- tests/qemuargv2xmldata/serial-udp.args | 23 -- tests/qemuargv2xmldata/serial-udp.xml | 52 --- tests/qemuargv2xmldata/serial-unix.args | 22 -- tests/qemuargv2xmldata/serial-unix.xml | 44 --- tests/qemuargv2xmldata/serial-vc.args | 22 -- tests/qemuargv2xmldata/serial-vc.xml | 42 --- tests/qemuargv2xmldata/smp.args | 22 -- tests/qemuargv2xmldata/smp.xml | 37 -- tests/qemuargv2xmldata/sound.args | 23 -- tests/qemuargv2xmldata/sound.xml | 42 --- tests/qemuargv2xmldata/watchdog.args | 24 -- tests/qemuargv2xmldata/watchdog.xml | 35 -- tests/qemuargv2xmltest.c | 323 ------------------ tests/virschematest.c | 2 +- 195 files changed, 3 insertions(+), 6243 deletions(-) delete mode 100644 tests/qemuargv2xmldata/boot-cdrom.args delete mode 100644 tests/qemuargv2xmldata/boot-cdrom.xml delete mode 100644 tests/qemuargv2xmldata/boot-floppy.args delete mode 100644 tests/qemuargv2xmldata/boot-floppy.xml delete mode 100644 tests/qemuargv2xmldata/boot-network.args delete mode 100644 tests/qemuargv2xmldata/boot-network.xml delete mode 100644 tests/qemuargv2xmldata/clock-localtime.args delete mode 100644 tests/qemuargv2xmldata/clock-localtime.xml delete mode 100644 tests/qemuargv2xmldata/clock-utc.args delete mode 100644 tests/qemuargv2xmldata/clock-utc.xml delete mode 100644 tests/qemuargv2xmldata/console-compat.args delete mode 100644 tests/qemuargv2xmldata/console-compat.xml delete mode 100644 tests/qemuargv2xmldata/disk-cdrom-empty.args delete mode 100644 tests/qemuargv2xmldata/disk-cdrom-empty.xml delete mode 100644 tests/qemuargv2xmldata/disk-cdrom.args delete mode 100644 tests/qemuargv2xmldata/disk-cdrom.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-boot-cdrom.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-boot-cdrom.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-boot-disk.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-boot-disk.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-directsync.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-directsync.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-unsafe.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-unsafe.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-v2-none.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-v2-none.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-v2-wb.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-v2-wb.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-v2-wt.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-cache-v2-wt.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-error-policy-enospace= .args delete mode 100644 tests/qemuargv2xmldata/disk-drive-error-policy-enospace= .xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-error-policy-stop.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-error-policy-stop.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-error-policy-wreport-= rignore.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-error-policy-wreport-= rignore.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-fmt-qcow.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-fmt-qcow.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-gluster.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-gluster.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-iscsi-auth.ar= gs delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-iscsi-auth.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-iscsi.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-iscsi.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-export.ar= gs delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-export.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-ipv6-expo= rt.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-ipv6-expo= rt.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-ipv6.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-ipv6.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-unix.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd-unix.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-nbd.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd-auth.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd-auth.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd-ceph-env.= args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd-ceph-env.= xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd-ipv6.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd-ipv6.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-rbd.xml delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-sheepdog.args delete mode 100644 tests/qemuargv2xmldata/disk-drive-network-sheepdog.xml delete mode 100644 tests/qemuargv2xmldata/disk-floppy.args delete mode 100644 tests/qemuargv2xmldata/disk-floppy.xml delete mode 100644 tests/qemuargv2xmldata/disk-many.args delete mode 100644 tests/qemuargv2xmldata/disk-many.xml delete mode 100644 tests/qemuargv2xmldata/disk-usb.args delete mode 100644 tests/qemuargv2xmldata/disk-usb.xml delete mode 100644 tests/qemuargv2xmldata/disk-virtio.args delete mode 100644 tests/qemuargv2xmldata/disk-virtio.xml delete mode 100644 tests/qemuargv2xmldata/graphics-sdl-fullscreen.args delete mode 100644 tests/qemuargv2xmldata/graphics-sdl-fullscreen.xml delete mode 100644 tests/qemuargv2xmldata/graphics-sdl.args delete mode 100644 tests/qemuargv2xmldata/graphics-sdl.xml delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-policy.args delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-policy.xml delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-sasl.args delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-sasl.xml delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-socket.args delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-socket.xml delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-tls.args delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-tls.xml delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-websocket.args delete mode 100644 tests/qemuargv2xmldata/graphics-vnc-websocket.xml delete mode 100644 tests/qemuargv2xmldata/graphics-vnc.args delete mode 100644 tests/qemuargv2xmldata/graphics-vnc.xml delete mode 100644 tests/qemuargv2xmldata/hostdev-pci-address.args delete mode 100644 tests/qemuargv2xmldata/hostdev-pci-address.xml delete mode 100644 tests/qemuargv2xmldata/hostdev-usb-address.args delete mode 100644 tests/qemuargv2xmldata/hostdev-usb-address.xml delete mode 100644 tests/qemuargv2xmldata/hyperv-panic.args delete mode 100644 tests/qemuargv2xmldata/hyperv-panic.xml delete mode 100644 tests/qemuargv2xmldata/hyperv.args delete mode 100644 tests/qemuargv2xmldata/hyperv.xml delete mode 100644 tests/qemuargv2xmldata/input-usbmouse.args delete mode 100644 tests/qemuargv2xmldata/input-usbmouse.xml delete mode 100644 tests/qemuargv2xmldata/input-usbtablet.args delete mode 100644 tests/qemuargv2xmldata/input-usbtablet.xml delete mode 100644 tests/qemuargv2xmldata/kvm-features.args delete mode 100644 tests/qemuargv2xmldata/kvm-features.xml delete mode 100644 tests/qemuargv2xmldata/kvmclock.args delete mode 100644 tests/qemuargv2xmldata/kvmclock.xml delete mode 100644 tests/qemuargv2xmldata/machine-aeskeywrap-off-argv.args delete mode 100644 tests/qemuargv2xmldata/machine-aeskeywrap-off-argv.xml delete mode 100644 tests/qemuargv2xmldata/machine-aeskeywrap-on-argv.args delete mode 100644 tests/qemuargv2xmldata/machine-aeskeywrap-on-argv.xml delete mode 100644 tests/qemuargv2xmldata/machine-core-off.args delete mode 100644 tests/qemuargv2xmldata/machine-core-off.xml delete mode 100644 tests/qemuargv2xmldata/machine-core-on.args delete mode 100644 tests/qemuargv2xmldata/machine-core-on.xml delete mode 100644 tests/qemuargv2xmldata/machine-deakeywrap-off-argv.args delete mode 100644 tests/qemuargv2xmldata/machine-deakeywrap-off-argv.xml delete mode 100644 tests/qemuargv2xmldata/machine-deakeywrap-on-argv.args delete mode 100644 tests/qemuargv2xmldata/machine-deakeywrap-on-argv.xml delete mode 100644 tests/qemuargv2xmldata/machine-keywrap-none-argv.args delete mode 100644 tests/qemuargv2xmldata/machine-keywrap-none-argv.xml delete mode 100644 tests/qemuargv2xmldata/mem-scale-maxmemory.args delete mode 100644 tests/qemuargv2xmldata/mem-scale-maxmemory.xml delete mode 100644 tests/qemuargv2xmldata/mem-scale.args delete mode 100644 tests/qemuargv2xmldata/mem-scale.xml delete mode 100644 tests/qemuargv2xmldata/migrate.args delete mode 100644 tests/qemuargv2xmldata/migrate.xml delete mode 100644 tests/qemuargv2xmldata/misc-acpi.args delete mode 100644 tests/qemuargv2xmldata/misc-acpi.xml delete mode 100644 tests/qemuargv2xmldata/misc-disable-s3.args delete mode 100644 tests/qemuargv2xmldata/misc-disable-s3.xml delete mode 100644 tests/qemuargv2xmldata/misc-disable-suspends.args delete mode 100644 tests/qemuargv2xmldata/misc-disable-suspends.xml delete mode 100644 tests/qemuargv2xmldata/misc-enable-s4.args delete mode 100644 tests/qemuargv2xmldata/misc-enable-s4.xml delete mode 100644 tests/qemuargv2xmldata/misc-no-reboot.args delete mode 100644 tests/qemuargv2xmldata/misc-no-reboot.xml delete mode 100644 tests/qemuargv2xmldata/misc-uuid.args delete mode 100644 tests/qemuargv2xmldata/misc-uuid.xml delete mode 100644 tests/qemuargv2xmldata/net-eth-ifname.args delete mode 100644 tests/qemuargv2xmldata/net-eth-ifname.xml delete mode 100644 tests/qemuargv2xmldata/net-eth.args delete mode 100644 tests/qemuargv2xmldata/net-eth.xml delete mode 100644 tests/qemuargv2xmldata/net-user.args delete mode 100644 tests/qemuargv2xmldata/net-user.xml delete mode 100644 tests/qemuargv2xmldata/net-virtio.args delete mode 100644 tests/qemuargv2xmldata/net-virtio.xml delete mode 100644 tests/qemuargv2xmldata/nographics-vga-display.args delete mode 100644 tests/qemuargv2xmldata/nographics-vga-display.xml delete mode 100644 tests/qemuargv2xmldata/nographics-vga.args delete mode 100644 tests/qemuargv2xmldata/nographics-vga.xml delete mode 100644 tests/qemuargv2xmldata/nomachine-ppc64.args delete mode 100644 tests/qemuargv2xmldata/nomachine-ppc64.xml delete mode 100644 tests/qemuargv2xmldata/nomachine-x86_64.args delete mode 100644 tests/qemuargv2xmldata/nomachine-x86_64.xml delete mode 100644 tests/qemuargv2xmldata/nosharepages.args delete mode 100644 tests/qemuargv2xmldata/nosharepages.xml delete mode 100644 tests/qemuargv2xmldata/parallel-tcp.args delete mode 100644 tests/qemuargv2xmldata/parallel-tcp.xml delete mode 100644 tests/qemuargv2xmldata/pseries-disk.args delete mode 100644 tests/qemuargv2xmldata/pseries-disk.xml delete mode 100644 tests/qemuargv2xmldata/pseries-nvram.args delete mode 100644 tests/qemuargv2xmldata/pseries-nvram.xml delete mode 100644 tests/qemuargv2xmldata/qemu-ns-no-env.args delete mode 100644 tests/qemuargv2xmldata/qemu-ns-no-env.xml delete mode 100644 tests/qemuargv2xmldata/reboot-timeout-disabled.args delete mode 100644 tests/qemuargv2xmldata/reboot-timeout-disabled.xml delete mode 100644 tests/qemuargv2xmldata/reboot-timeout-enabled.args delete mode 100644 tests/qemuargv2xmldata/reboot-timeout-enabled.xml delete mode 100644 tests/qemuargv2xmldata/restore-v2.args delete mode 100644 tests/qemuargv2xmldata/restore-v2.xml delete mode 100644 tests/qemuargv2xmldata/serial-dev.args delete mode 100644 tests/qemuargv2xmldata/serial-dev.xml delete mode 100644 tests/qemuargv2xmldata/serial-file.args delete mode 100644 tests/qemuargv2xmldata/serial-file.xml delete mode 100644 tests/qemuargv2xmldata/serial-many.args delete mode 100644 tests/qemuargv2xmldata/serial-many.xml delete mode 100644 tests/qemuargv2xmldata/serial-pty.args delete mode 100644 tests/qemuargv2xmldata/serial-pty.xml delete mode 100644 tests/qemuargv2xmldata/serial-tcp-telnet.args delete mode 100644 tests/qemuargv2xmldata/serial-tcp-telnet.xml delete mode 100644 tests/qemuargv2xmldata/serial-tcp.args delete mode 100644 tests/qemuargv2xmldata/serial-tcp.xml delete mode 100644 tests/qemuargv2xmldata/serial-udp.args delete mode 100644 tests/qemuargv2xmldata/serial-udp.xml delete mode 100644 tests/qemuargv2xmldata/serial-unix.args delete mode 100644 tests/qemuargv2xmldata/serial-unix.xml delete mode 100644 tests/qemuargv2xmldata/serial-vc.args delete mode 100644 tests/qemuargv2xmldata/serial-vc.xml delete mode 100644 tests/qemuargv2xmldata/smp.args delete mode 100644 tests/qemuargv2xmldata/smp.xml delete mode 100644 tests/qemuargv2xmldata/sound.args delete mode 100644 tests/qemuargv2xmldata/sound.xml delete mode 100644 tests/qemuargv2xmldata/watchdog.args delete mode 100644 tests/qemuargv2xmldata/watchdog.xml delete mode 100644 tests/qemuargv2xmltest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 5ba529124a..0f51a8944f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -109,7 +109,6 @@ EXTRA_DIST =3D \ nwfilterxml2xmlout \ oomtrace.pl \ qemuagentdata \ - qemuargv2xmldata \ qemublocktestdata \ qemucapabilitiesdata \ qemucaps2xmloutdata \ @@ -275,7 +274,7 @@ endif WITH_LIBXL if WITH_QEMU test_programs +=3D qemuxml2argvtest qemuxml2xmltest \ - qemuargv2xmltest domainsnapshotxml2xmltest \ + domainsnapshotxml2xmltest \ qemumonitorjsontest qemuhotplugtest \ qemuagenttest qemucapabilitiestest qemucaps2xmltest \ qemumemlocktest \ @@ -583,12 +582,6 @@ qemuxml2xmltest_SOURCES =3D \ testutils.c testutils.h qemuxml2xmltest_LDADD =3D $(qemu_LDADDS) -qemuargv2xmltest_SOURCES =3D \ - qemuargv2xmltest.c testutilsqemu.c testutilsqemu.h \ - testutils.c testutils.h -qemuargv2xmltest_LDADD =3D libqemutestdriver.la \ - $(LDADDS) - qemumonitorjsontest_SOURCES =3D \ qemumonitorjsontest.c \ testutils.c testutils.h \ @@ -695,7 +688,7 @@ qemufirmwaretest_SOURCES =3D \ qemufirmwaretest_LDADD =3D $(qemu_LDADDS) else ! WITH_QEMU -EXTRA_DIST +=3D qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \ +EXTRA_DIST +=3D qemuxml2argvtest.c qemuxml2xmltest.c \ domainsnapshotxml2xmltest.c \ testutilsqemu.c testutilsqemu.h \ testutilsqemuschema.c testutilsqemuschema.h \ diff --git a/tests/qemuargv2xmldata/boot-cdrom.args b/tests/qemuargv2xmldat= a/boot-cdrom.args deleted file mode 100644 index 6a7e0e2867..0000000000 --- a/tests/qemuargv2xmldata/boot-cdrom.args +++ /dev/null @@ -1,22 +0,0 @@ -LC_ALL=3DC \ -PATH=3D/bin \ -HOME=3D/home/test \ -USER=3Dtest \ -LOGNAME=3Dtest \ -QEMU_AUDIO_DRV=3Dnone \ -/usr/bin/qemu-system-i686 \ --name QEMUGuest1 \ --S \ --M pc \ --m 214 \ --smp 1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --nographic \ --monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi \ --boot d \ --usb \ --drive file=3D/dev/cdrom,format=3Draw,if=3Dide,media=3Dcdrom,bus=3D1,unit= =3D0 \ --net none \ --serial none \ --parallel none [... truncated ... all tests are purely deleted ...] -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:52:50 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560519275; cv=none; d=zoho.com; s=zohoarc; b=mV+WoBWAItf21WjI4z5HXn/LDE1ssvKDcnCzFZ9iayuKJWLoUX5Qa3hLj3LuZKU72OchxAjot77FUBcSJoE4QvHZoO4gw5OUz4fGnOHiF8HtqEVBzNfyEdyAu2ulGGxMEg4v7ywi+9hEp50bmNbnwbv0iG6aopifnq7FZ8NK8No= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560519275; 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:ARC-Authentication-Results; bh=2Y8usvdexJTzTjOTdMrV1RF/rjbi94I1KWN/fYI1ykg=; b=YlOTSVZhL0B0/muFAPQUa9EwHbR9SOdX0f7/VhysedQgY882QjdsoUUD3fhbi045x6YQDJCVLWC6WeK50OumEG8MUPXGYw0FLCS4kzWdMzxI/QkX4KPuPE5kpAREW6VOGb9X7oLyNECgxKgrgw8rO+XkQ0ZsMu0HbPYBGtFunVc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560519274994423.4774132460757; Fri, 14 Jun 2019 06:34:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38F4F8830C; Fri, 14 Jun 2019 13:34:28 +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 0C21519C67; Fri, 14 Jun 2019 13:34:26 +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 BCB551806B0F; Fri, 14 Jun 2019 13:34:22 +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 x5EDUZHr019835 for ; Fri, 14 Jun 2019 09:30:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8FECA2CE56; Fri, 14 Jun 2019 13:30:35 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C32631753B for ; Fri, 14 Jun 2019 13:30:34 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 14 Jun 2019 15:30:27 +0200 Message-Id: <62f8136a0a657b0f84934de66c01925f87beac55.1560518789.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 5/5] qemu: parse: Drop unused qemu command line parsing infrastructure 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: , 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 14 Jun 2019 13:34:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It's now unused and utterly obsolete. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 2 + src/qemu/qemu_parse_command.c | 2622 +-------------------------------- src/qemu/qemu_parse_command.h | 16 - 3 files changed, 3 insertions(+), 2637 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e5c6ef3fda..8f754fbf06 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -76,6 +76,8 @@ #define VIR_FROM_THIS VIR_FROM_QEMU +#define QEMU_QXL_VGAMEM_DEFAULT 16 * 1024 + VIR_LOG_INIT("qemu.qemu_domain"); #define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0" diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index b522882c78..b49aa92fb3 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -21,363 +21,17 @@ #include -#include "qemu_command.h" #include "qemu_parse_command.h" -#include "dirname.h" #include "viralloc.h" #include "virlog.h" -#include "virsecret.h" #include "virstring.h" -#include "c-ctype.h" +#include "virerror.h" #define VIR_FROM_THIS VIR_FROM_QEMU VIR_LOG_INIT("qemu.qemu_parse_command"); -static int -qemuParseRBDString(virDomainDiskDefPtr disk) -{ - char *source =3D disk->src->path; - int ret; - - disk->src->path =3D NULL; - - ret =3D virStorageSourceParseRBDColonString(source, disk->src); - - VIR_FREE(source); - return ret; -} - - -static int -qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri, - const char *scheme) -{ - int ret =3D -1; - char *transp =3D NULL; - char *sock =3D NULL; - char *volimg =3D NULL; - char *secret =3D NULL; - VIR_AUTOPTR(virStorageAuthDef) authdef =3D NULL; - - if (VIR_ALLOC(def->src->hosts) < 0) - goto error; - - transp =3D strchr(uri->scheme, '+'); - if (transp) - *transp++ =3D 0; - - if (STRNEQ(uri->scheme, scheme)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid transport/scheme '%s'"), uri->scheme); - goto error; - } - - if (!transp) { - def->src->hosts->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - } else { - def->src->hosts->transport =3D virStorageNetHostTransportTypeFromS= tring(transp); - if (def->src->hosts->transport < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid %s transport type '%s'"), scheme, tr= ansp); - goto error; - } - } - def->src->nhosts =3D 0; /* set to 1 once everything succeeds */ - - if (def->src->hosts->transport !=3D VIR_STORAGE_NET_HOST_TRANS_UNIX) { - if (VIR_STRDUP(def->src->hosts->name, uri->server) < 0) - goto error; - - def->src->hosts->port =3D uri->port; - } else { - def->src->hosts->name =3D NULL; - def->src->hosts->port =3D 0; - if (uri->query) { - if (STRPREFIX(uri->query, "socket=3D")) { - sock =3D strchr(uri->query, '=3D') + 1; - if (VIR_STRDUP(def->src->hosts->socket, sock) < 0) - goto error; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid query parameter '%s'"), uri->que= ry); - goto error; - } - } - } - if (uri->path) { - volimg =3D uri->path + 1; /* skip the prefix slash */ - VIR_FREE(def->src->path); - if (VIR_STRDUP(def->src->path, volimg) < 0) - goto error; - } else { - VIR_FREE(def->src->path); - } - - if (uri->user) { - const char *secrettype; - /* formulate authdef for disk->src->auth */ - if (VIR_ALLOC(authdef) < 0) - goto error; - - secret =3D strchr(uri->user, ':'); - if (secret) - *secret =3D '\0'; - - if (VIR_STRDUP(authdef->username, uri->user) < 0) - goto error; - if (STREQ(scheme, "iscsi")) { - secrettype =3D - virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); - if (VIR_STRDUP(authdef->secrettype, secrettype) < 0) - goto error; - } - VIR_STEAL_PTR(def->src->auth, authdef); - - /* Cannot formulate a secretType (eg, usage or uuid) given - * what is provided. - */ - } - - def->src->nhosts =3D 1; - ret =3D 0; - - cleanup: - virURIFree(uri); - - return ret; - - error: - virStorageNetHostDefClear(def->src->hosts); - VIR_FREE(def->src->hosts); - goto cleanup; -} - -static int -qemuParseGlusterString(virDomainDiskDefPtr def) -{ - virURIPtr uri =3D NULL; - - if (!(uri =3D virURIParse(def->src->path))) - return -1; - - return qemuParseDriveURIString(def, uri, "gluster"); -} - -static int -qemuParseISCSIString(virDomainDiskDefPtr def) -{ - virURIPtr uri =3D NULL; - char *slash; - unsigned lun; - - if (!(uri =3D virURIParse(def->src->path))) - return -1; - - if (uri->path && - (slash =3D strchr(uri->path + 1, '/')) !=3D NULL) { - - if (slash[1] =3D=3D '\0') { - *slash =3D '\0'; - } else if (virStrToLong_ui(slash + 1, NULL, 10, &lun) =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid name '%s' for iSCSI disk"), - def->src->path); - virURIFree(uri); - return -1; - } - } - - return qemuParseDriveURIString(def, uri, "iscsi"); -} - -static int -qemuParseNBDString(virDomainDiskDefPtr disk) -{ - virStorageNetHostDefPtr h =3D NULL; - char *host, *port; - char *src; - - virURIPtr uri =3D NULL; - - if (strstr(disk->src->path, "://")) { - if (!(uri =3D virURIParse(disk->src->path))) - return -1; - return qemuParseDriveURIString(disk, uri, "nbd"); - } - - if (VIR_ALLOC(h) < 0) - goto error; - - host =3D disk->src->path + strlen("nbd:"); - if (STRPREFIX(host, "unix:/")) { - src =3D strchr(host + strlen("unix:"), ':'); - if (src) - *src++ =3D '\0'; - - h->transport =3D VIR_STORAGE_NET_HOST_TRANS_UNIX; - if (VIR_STRDUP(h->socket, host + strlen("unix:")) < 0) - goto error; - } else { - port =3D strchr(host, ':'); - if (!port) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse nbd filename '%s'"), disk->src-= >path); - goto error; - } - - *port++ =3D '\0'; - if (VIR_STRDUP(h->name, host) < 0) - goto error; - - src =3D strchr(port, ':'); - if (src) - *src++ =3D '\0'; - - if (virStringParsePort(port, &h->port) < 0) - goto error; - } - - if (src && STRPREFIX(src, "exportname=3D")) { - if (VIR_STRDUP(src, strchr(src, '=3D') + 1) < 0) - goto error; - } else { - src =3D NULL; - } - - VIR_FREE(disk->src->path); - disk->src->path =3D src; - disk->src->nhosts =3D 1; - disk->src->hosts =3D h; - return 0; - - error: - virStorageNetHostDefClear(h); - VIR_FREE(h); - return -1; -} - - -/* - * This method takes a string representing a QEMU command line ARGV set - * optionally prefixed by a list of environment variables. It then tries - * to split it up into a NULL terminated list of env & argv, splitting - * on space - */ -static int qemuStringToArgvEnv(const char *args, - char ***retenv, - char ***retargv) -{ - char **arglist =3D NULL; - size_t argcount =3D 0; - size_t argalloc =3D 0; - size_t envend; - size_t i; - const char *curr =3D args; - const char *start; - char **progenv =3D NULL; - char **progargv =3D NULL; - - /* Iterate over string, splitting on sequences of ' ' */ - while (curr && *curr !=3D '\0') { - char *arg; - const char *next; - - start =3D curr; - /* accept a space in CEPH_ARGS */ - if (STRPREFIX(curr, "CEPH_ARGS=3D-m ")) - start +=3D strlen("CEPH_ARGS=3D-m "); - if (*start =3D=3D '\'') { - if (start =3D=3D curr) - curr++; - next =3D strchr(start + 1, '\''); - } else if (*start =3D=3D '"') { - if (start =3D=3D curr) - curr++; - next =3D strchr(start + 1, '"'); - } else { - next =3D strchr(start, ' '); - } - if (!next) - next =3D strchr(curr, '\n'); - - if (VIR_STRNDUP(arg, curr, next ? next - curr : -1) < 0) - goto error; - - if (next && (*next =3D=3D '\'' || *next =3D=3D '"')) - next++; - - if (VIR_RESIZE_N(arglist, argalloc, argcount, 2) < 0) { - VIR_FREE(arg); - goto error; - } - - arglist[argcount++] =3D arg; - arglist[argcount] =3D NULL; - - while (next && c_isspace(*next)) - next++; - - curr =3D next; - } - - /* Iterate over list of args, finding first arg not containing - * the '=3D' character (eg, skip over env vars FOO=3Dbar) */ - for (envend =3D 0; ((envend < argcount) && - (strchr(arglist[envend], '=3D') !=3D NULL)); - envend++) - ; /* nada */ - - /* Copy the list of env vars */ - if (envend > 0) { - if (VIR_REALLOC_N(progenv, envend+1) < 0) - goto error; - for (i =3D 0; i < envend; i++) - progenv[i] =3D arglist[i]; - progenv[i] =3D NULL; - } - - /* Copy the list of argv */ - if (VIR_REALLOC_N(progargv, argcount-envend + 1) < 0) - goto error; - for (i =3D envend; i < argcount; i++) - progargv[i-envend] =3D arglist[i]; - progargv[i-envend] =3D NULL; - - VIR_FREE(arglist); - - *retenv =3D progenv; - *retargv =3D progargv; - - return 0; - - error: - VIR_FREE(progenv); - VIR_FREE(progargv); - virStringListFree(arglist); - return -1; -} - - -/* - * Search for a named env variable, and return the value part - */ -static const char *qemuFindEnv(char **progenv, - const char *name) -{ - size_t i; - int len =3D strlen(name); - - for (i =3D 0; progenv && progenv[i]; i++) { - if (STREQLEN(progenv[i], name, len) && - progenv[i][len] =3D=3D '=3D') - return progenv[i] + len + 1; - } - return NULL; -} - - void qemuParseKeywordsFree(int nkeywords, char **keywords, @@ -493,2277 +147,3 @@ qemuParseKeywords(const char *str, qemuParseKeywordsFree(keywordCount, keywords, values); return -1; } - - -/* qemuParseCommandLineVnc - * - * Tries to parse the various "-vnc ..." argument formats. - */ -static int -qemuParseCommandLineVnc(virDomainDefPtr def, - const char *val) -{ - int ret =3D -1; - virDomainGraphicsDefPtr vnc =3D NULL; - char *listenAddr =3D NULL; - char *tmp; - - if (VIR_ALLOC(vnc) < 0) - goto cleanup; - vnc->type =3D VIR_DOMAIN_GRAPHICS_TYPE_VNC; - - if (STRPREFIX(val, "unix:")) { - /* -vnc unix:/some/big/path */ - if (virDomainGraphicsListenAppendSocket(vnc, val + 5) < 0) - goto cleanup; - } else { - /* - * -vnc 127.0.0.1:4 - * -vnc [2001:1:2:3:4:5:1234:1234]:4 - * -vnc some.host.name:4 - */ - char *opts; - char *port; - const char *sep =3D ":"; - if (val[0] =3D=3D '[') - sep =3D "]:"; - tmp =3D strstr(val, sep); - if (!tmp) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing VNC port number in '%s'"), val); - goto cleanup; - } - port =3D tmp + strlen(sep); - if (virStrToLong_i(port, &opts, 10, - &vnc->data.vnc.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse VNC port '%s'"), port); - goto cleanup; - } - if (val[0] =3D=3D '[') - val++; - if (VIR_STRNDUP(listenAddr, val, tmp-val) < 0 || - virDomainGraphicsListenAppendAddress(vnc, listenAddr) < 0) - goto cleanup; - - if (*opts =3D=3D ',') { - char *orig_opts; - - if (VIR_STRDUP(orig_opts, opts + 1) < 0) - goto cleanup; - opts =3D orig_opts; - - while (opts && *opts) { - char *nextopt =3D strchr(opts, ','); - if (nextopt) - *(nextopt++) =3D '\0'; - - if (STRPREFIX(opts, "websocket")) { - char *websocket =3D opts + strlen("websocket"); - if (*(websocket++) =3D=3D '=3D' && - *websocket) { - /* If the websocket continues with - * '=3D', we'll parse it */ - if (virStrToLong_i(websocket, - NULL, 0, - &vnc->data.vnc.websocket) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse VNC " - "WebSocket port '%s'"), - websocket); - VIR_FREE(orig_opts); - goto cleanup; - } - } else { - /* Otherwise, we'll compute the port the same - * way QEMU does, by adding a 5700 to the - * display value. */ - vnc->data.vnc.websocket =3D - vnc->data.vnc.port + 5700; - } - } else if (STRPREFIX(opts, "share=3D")) { - char *sharePolicy =3D opts + strlen("share=3D"); - if (sharePolicy && *sharePolicy) { - int policy =3D - virDomainGraphicsVNCSharePolicyTypeFromString(= sharePolicy); - - if (policy < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown vnc display sharing = policy '%s'"), - sharePolicy); - VIR_FREE(orig_opts); - goto cleanup; - } else { - vnc->data.vnc.sharePolicy =3D policy; - } - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing vnc sharing policy")); - VIR_FREE(orig_opts); - goto cleanup; - } - } - - opts =3D nextopt; - } - VIR_FREE(orig_opts); - } - vnc->data.vnc.port +=3D 5900; - vnc->data.vnc.autoport =3D false; - } - - if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, vnc) < 0) - goto cleanup; - - ret =3D 0; - - cleanup: - virDomainGraphicsDefFree(vnc); - VIR_FREE(listenAddr); - return ret; -} - - -/* - * Tries to parse new style QEMU -drive args. - * - * eg -drive file=3D/dev/HostVG/VirtData1,if=3Dide,index=3D1 - * - * Will fail if not using the 'index' keyword - */ -static virDomainDiskDefPtr -qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, - const char *val, - virDomainDefPtr dom, - int nvirtiodisk, - bool old_style_ceph_args) -{ - virDomainDiskDefPtr def =3D NULL; - char **keywords; - char **values; - int nkeywords; - size_t i; - int idx =3D -1; - int busid =3D -1; - int unitid =3D -1; - - if (qemuParseKeywords(val, - &keywords, - &values, - &nkeywords, - 0) < 0) - return NULL; - - if (!(def =3D virDomainDiskDefNew(xmlopt))) - goto cleanup; - - if (qemuDomainIsPSeries(dom)) - def->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; - else - def->bus =3D VIR_DOMAIN_DISK_BUS_IDE; - def->device =3D VIR_DOMAIN_DISK_DEVICE_DISK; - def->src->type =3D VIR_STORAGE_TYPE_FILE; - - for (i =3D 0; i < nkeywords; i++) { - if (STREQ(keywords[i], "file")) { - if (values[i] && STRNEQ(values[i], "")) { - def->src->path =3D values[i]; - values[i] =3D NULL; - if (STRPREFIX(def->src->path, "/dev/")) - def->src->type =3D VIR_STORAGE_TYPE_BLOCK; - else if (STRPREFIX(def->src->path, "nbd:") || - STRPREFIX(def->src->path, "nbd+")) { - def->src->type =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_NBD; - - if (qemuParseNBDString(def) < 0) - goto error; - } else if (STRPREFIX(def->src->path, "rbd:")) { - char *p =3D def->src->path; - - def->src->type =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_RBD; - if (VIR_STRDUP(def->src->path, p + strlen("rbd:")) < 0) - goto error; - /* old-style CEPH_ARGS env variable is parsed later */ - if (!old_style_ceph_args && qemuParseRBDString(def) < = 0) { - VIR_FREE(p); - goto error; - } - - VIR_FREE(p); - } else if (STRPREFIX(def->src->path, "gluster:") || - STRPREFIX(def->src->path, "gluster+")) { - def->src->type =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_GLUSTE= R; - - if (qemuParseGlusterString(def) < 0) - goto error; - } else if (STRPREFIX(def->src->path, "iscsi:")) { - def->src->type =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - - if (qemuParseISCSIString(def) < 0) - goto error; - } else if (STRPREFIX(def->src->path, "sheepdog:")) { - char *p =3D def->src->path; - char *port, *vdi; - - def->src->type =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_SHEEPD= OG; - if (VIR_STRDUP(def->src->path, p + strlen("sheepdog:")= ) < 0) - goto error; - VIR_FREE(p); - - /* def->src->path must be [vdiname] or [host]:[port]:[= vdiname] */ - port =3D strchr(def->src->path, ':'); - if (port) { - *port =3D '\0'; - vdi =3D strchr(port + 1, ':'); - if (!vdi) { - *port =3D ':'; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse sheepdog filena= me '%s'"), - def->src->path); - goto error; - } - port++; - *vdi++ =3D '\0'; - if (VIR_ALLOC(def->src->hosts) < 0) - goto error; - def->src->nhosts =3D 1; - def->src->hosts->name =3D def->src->path; - if (virStringParsePort(port, &def->src->hosts->por= t) < 0) - goto error; - def->src->hosts->transport =3D VIR_STORAGE_NET_HOS= T_TRANS_TCP; - def->src->hosts->socket =3D NULL; - if (VIR_STRDUP(def->src->path, vdi) < 0) - goto error; - } - } else if (STRPREFIX(def->src->path, "vxhs:")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("VxHS protocol does not support URI s= yntax '%s'"), - def->src->path); - goto error; - } else { - def->src->type =3D VIR_STORAGE_TYPE_FILE; - } - } else { - def->src->type =3D VIR_STORAGE_TYPE_FILE; - } - } else if (STREQ(keywords[i], "if")) { - if (STREQ(values[i], "ide")) { - def->bus =3D VIR_DOMAIN_DISK_BUS_IDE; - if (qemuDomainIsPSeries(dom)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("pseries systems do not support ide d= evices '%s'"), val); - goto error; - } - } else if (STREQ(values[i], "scsi")) { - def->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; - } else if (STREQ(values[i], "floppy")) { - def->bus =3D VIR_DOMAIN_DISK_BUS_FDC; - def->device =3D VIR_DOMAIN_DISK_DEVICE_FLOPPY; - } else if (STREQ(values[i], "virtio")) { - def->bus =3D VIR_DOMAIN_DISK_BUS_VIRTIO; - } else if (STREQ(values[i], "xen")) { - def->bus =3D VIR_DOMAIN_DISK_BUS_XEN; - } else if (STREQ(values[i], "sd")) { - def->bus =3D VIR_DOMAIN_DISK_BUS_SD; - } - } else if (STREQ(keywords[i], "media")) { - if (STREQ(values[i], "cdrom")) { - def->device =3D VIR_DOMAIN_DISK_DEVICE_CDROM; - def->src->readonly =3D true; - } else if (STREQ(values[i], "floppy")) { - def->device =3D VIR_DOMAIN_DISK_DEVICE_FLOPPY; - } - } else if (STREQ(keywords[i], "format")) { - if (virDomainDiskSetDriver(def, "qemu") < 0) - goto error; - def->src->format =3D virStorageFileFormatTypeFromString(values= [i]); - } else if (STREQ(keywords[i], "cache")) { - if (STREQ(values[i], "off") || - STREQ(values[i], "none")) - def->cachemode =3D VIR_DOMAIN_DISK_CACHE_DISABLE; - else if (STREQ(values[i], "writeback") || - STREQ(values[i], "on")) - def->cachemode =3D VIR_DOMAIN_DISK_CACHE_WRITEBACK; - else if (STREQ(values[i], "writethrough")) - def->cachemode =3D VIR_DOMAIN_DISK_CACHE_WRITETHRU; - else if (STREQ(values[i], "directsync")) - def->cachemode =3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC; - else if (STREQ(values[i], "unsafe")) - def->cachemode =3D VIR_DOMAIN_DISK_CACHE_UNSAFE; - } else if (STREQ(keywords[i], "werror")) { - if (STREQ(values[i], "stop")) - def->error_policy =3D VIR_DOMAIN_DISK_ERROR_POLICY_STOP; - else if (STREQ(values[i], "report")) - def->error_policy =3D VIR_DOMAIN_DISK_ERROR_POLICY_REPORT; - else if (STREQ(values[i], "ignore")) - def->error_policy =3D VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE; - else if (STREQ(values[i], "enospc")) - def->error_policy =3D VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPAC= E; - } else if (STREQ(keywords[i], "rerror")) { - if (STREQ(values[i], "stop")) - def->rerror_policy =3D VIR_DOMAIN_DISK_ERROR_POLICY_STOP; - else if (STREQ(values[i], "report")) - def->rerror_policy =3D VIR_DOMAIN_DISK_ERROR_POLICY_REPORT; - else if (STREQ(values[i], "ignore")) - def->rerror_policy =3D VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE; - } else if (STREQ(keywords[i], "index")) { - if (virStrToLong_i(values[i], NULL, 10, &idx) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse drive index '%s'"), val); - goto error; - } - } else if (STREQ(keywords[i], "bus")) { - if (virStrToLong_i(values[i], NULL, 10, &busid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse drive bus '%s'"), val); - goto error; - } - } else if (STREQ(keywords[i], "unit")) { - if (virStrToLong_i(values[i], NULL, 10, &unitid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse drive unit '%s'"), val); - goto error; - } - } else if (STREQ(keywords[i], "readonly")) { - if ((values[i] =3D=3D NULL) || STREQ(values[i], "on")) - def->src->readonly =3D true; - } else if (STREQ(keywords[i], "aio")) { - if ((def->iomode =3D virDomainDiskIoTypeFromString(values[i]))= < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse io mode '%s'"), values[i]); - goto error; - } - } else if (STREQ(keywords[i], "cyls")) { - if (virStrToLong_ui(values[i], NULL, 10, - &(def->geometry.cylinders)) < 0) { - virDomainDiskDefFree(def); - def =3D NULL; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse cylinders value'%s'"), - values[i]); - goto error; - } - } else if (STREQ(keywords[i], "heads")) { - if (virStrToLong_ui(values[i], NULL, 10, - &(def->geometry.heads)) < 0) { - virDomainDiskDefFree(def); - def =3D NULL; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse heads value'%s'"), - values[i]); - goto error; - } - } else if (STREQ(keywords[i], "secs")) { - if (virStrToLong_ui(values[i], NULL, 10, - &(def->geometry.sectors)) < 0) { - virDomainDiskDefFree(def); - def =3D NULL; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse sectors value'%s'"), - values[i]); - goto error; - } - } else if (STREQ(keywords[i], "trans")) { - def->geometry.trans =3D - virDomainDiskGeometryTransTypeFromString(values[i]); - if ((def->geometry.trans < VIR_DOMAIN_DISK_TRANS_DEFAULT) || - (def->geometry.trans >=3D VIR_DOMAIN_DISK_TRANS_LAST)) { - virDomainDiskDefFree(def); - def =3D NULL; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse translation value '%s'"), - values[i]); - goto error; - } - } - } - - if (def->rerror_policy =3D=3D def->error_policy) - def->rerror_policy =3D 0; - - if (!def->src->path && - def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK && - def->src->type !=3D VIR_STORAGE_TYPE_NETWORK) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing file parameter in drive '%s'"), val); - goto error; - } - if (idx =3D=3D -1 && - def->bus =3D=3D VIR_DOMAIN_DISK_BUS_VIRTIO) - idx =3D nvirtiodisk; - - if (idx =3D=3D -1 && - unitid =3D=3D -1 && - busid =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing index/unit/bus parameter in drive '%s'"), - val); - goto error; - } - - if (idx =3D=3D -1) { - if (unitid =3D=3D -1) - unitid =3D 0; - if (busid =3D=3D -1) - busid =3D 0; - switch (def->bus) { - case VIR_DOMAIN_DISK_BUS_IDE: - idx =3D (busid * 2) + unitid; - break; - case VIR_DOMAIN_DISK_BUS_SCSI: - idx =3D (busid * 7) + unitid; - break; - default: - idx =3D unitid; - break; - } - } - - if (def->bus =3D=3D VIR_DOMAIN_DISK_BUS_IDE) { - ignore_value(VIR_STRDUP(def->dst, "hda")); - } else if (def->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI || - def->bus =3D=3D VIR_DOMAIN_DISK_BUS_SD) { - ignore_value(VIR_STRDUP(def->dst, "sda")); - } else if (def->bus =3D=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { - ignore_value(VIR_STRDUP(def->dst, "vda")); - } else if (def->bus =3D=3D VIR_DOMAIN_DISK_BUS_XEN) { - ignore_value(VIR_STRDUP(def->dst, "xvda")); - } else if (def->bus =3D=3D VIR_DOMAIN_DISK_BUS_FDC) { - ignore_value(VIR_STRDUP(def->dst, "fda")); - } else { - ignore_value(VIR_STRDUP(def->dst, "hda")); - } - - if (!def->dst) - goto error; - if (STREQ(def->dst, "xvda")) - def->dst[3] =3D 'a' + idx; - else - def->dst[2] =3D 'a' + idx; - - if (virDomainDiskDefAssignAddress(xmlopt, def, dom) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid device name '%s'"), def->dst); - goto error; - } - - cleanup: - qemuParseKeywordsFree(nkeywords, keywords, values); - return def; - - error: - virDomainDiskDefFree(def); - def =3D NULL; - goto cleanup; -} - -/* - * Tries to find a NIC definition matching a vlan we want - */ -static const char * -qemuFindNICForVLAN(int nnics, - const char **nics, - int wantvlan) -{ - size_t i; - for (i =3D 0; i < nnics; i++) { - int gotvlan; - const char *tmp =3D strstr(nics[i], "vlan=3D"); - char *end; - if (!tmp) - continue; - - tmp +=3D strlen("vlan=3D"); - - if (virStrToLong_i(tmp, &end, 10, &gotvlan) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse NIC vlan in '%s'"), nics[i]); - return NULL; - } - - if (gotvlan =3D=3D wantvlan) - return nics[i]; - } - - if (wantvlan =3D=3D 0 && nnics > 0) - return nics[0]; - - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot find NIC definition for vlan %d"), wantvlan); - return NULL; -} - - -/* - * Tries to parse a QEMU -net backend argument. Gets given - * a list of all known -net frontend arguments to try and - * match up against. Horribly complicated stuff - */ -static virDomainNetDefPtr -qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, - const char *val, - int nnics, - const char **nics) -{ - virDomainNetDefPtr def =3D NULL; - char **keywords =3D NULL; - char **values =3D NULL; - int nkeywords; - const char *nic; - int wantvlan =3D 0; - const char *tmp; - bool genmac =3D true; - size_t i; - - tmp =3D strchr(val, ','); - - if (tmp) { - if (qemuParseKeywords(tmp+1, - &keywords, - &values, - &nkeywords, - 0) < 0) - return NULL; - } else { - nkeywords =3D 0; - } - - if (VIR_ALLOC(def) < 0) - goto cleanup; - - /* 'tap' could turn into libvirt type=3Dethernet, type=3Dbridge or - * type=3Dnetwork, but we can't tell, so use the generic config */ - if (STRPREFIX(val, "tap,")) - def->type =3D VIR_DOMAIN_NET_TYPE_ETHERNET; - else if (STRPREFIX(val, "socket")) - def->type =3D VIR_DOMAIN_NET_TYPE_CLIENT; - else if (STRPREFIX(val, "user")) - def->type =3D VIR_DOMAIN_NET_TYPE_USER; - else - def->type =3D VIR_DOMAIN_NET_TYPE_ETHERNET; - - for (i =3D 0; i < nkeywords; i++) { - if (STREQ(keywords[i], "vlan")) { - if (virStrToLong_i(values[i], NULL, 10, &wantvlan) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vlan in '%s'"), val); - goto error; - } - } else if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && - STREQ(keywords[i], "script") && STRNEQ(values[i], "")) { - def->script =3D values[i]; - values[i] =3D NULL; - } else if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && - STREQ(keywords[i], "ifname")) { - def->ifname =3D values[i]; - values[i] =3D NULL; - } - } - - - /* Done parsing the nic backend. Now to try and find corresponding - * frontend, based off vlan number. NB this assumes a 1-1 mapping - */ - - nic =3D qemuFindNICForVLAN(nnics, nics, wantvlan); - if (!nic) - goto error; - - if (!STRPREFIX(nic, "nic")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse NIC definition '%s'"), nic); - goto error; - } - - for (i =3D 0; i < nkeywords; i++) { - VIR_FREE(keywords[i]); - VIR_FREE(values[i]); - } - VIR_FREE(keywords); - VIR_FREE(values); - - if (STRPREFIX(nic, "nic,")) { - if (qemuParseKeywords(nic + strlen("nic,"), - &keywords, - &values, - &nkeywords, - 0) < 0) { - goto error; - } - } else { - nkeywords =3D 0; - } - - for (i =3D 0; i < nkeywords; i++) { - if (STREQ(keywords[i], "macaddr")) { - genmac =3D false; - if (virMacAddrParse(values[i], &def->mac) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to parse mac address '%s'"), - values[i]); - goto error; - } - } else if (STREQ(keywords[i], "model")) { - if (virDomainNetSetModelString(def, values[i]) < 0) - goto error; - VIR_FREE(values[i]); - } else if (STREQ(keywords[i], "vhost")) { - if ((values[i] =3D=3D NULL) || STREQ(values[i], "on")) { - def->driver.virtio.name =3D VIR_DOMAIN_NET_BACKEND_TYPE_VH= OST; - } else if (STREQ(keywords[i], "off")) { - def->driver.virtio.name =3D VIR_DOMAIN_NET_BACKEND_TYPE_QE= MU; - } - } else if (STREQ(keywords[i], "sndbuf") && values[i]) { - if (virStrToLong_ul(values[i], NULL, 10, &def->tune.sndbuf) < = 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse sndbuf size in '%s'"), val); - goto error; - } - def->tune.sndbuf_specified =3D true; - } - } - - if (genmac) - virDomainNetGenerateMAC(xmlopt, &def->mac); - - cleanup: - qemuParseKeywordsFree(nkeywords, keywords, values); - return def; - - error: - virDomainNetDefFree(def); - def =3D NULL; - goto cleanup; -} - - -/* - * Tries to parse a QEMU PCI device - */ -static virDomainHostdevDefPtr -qemuParseCommandLinePCI(const char *val) -{ - int bus =3D 0, slot =3D 0, func =3D 0; - const char *start; - char *end; - virDomainHostdevDefPtr def =3D virDomainHostdevDefNew(); - - if (!def) - goto error; - - if (!STRPREFIX(val, "host=3D")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown PCI device syntax '%s'"), val); - goto error; - } - - start =3D val + strlen("host=3D"); - if (virStrToLong_i(start, &end, 16, &bus) < 0 || *end !=3D ':') { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device bus '%s'"), val); - goto error; - } - start =3D end + 1; - if (virStrToLong_i(start, &end, 16, &slot) < 0 || *end !=3D '.') { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device slot '%s'"), val); - goto error; - } - start =3D end + 1; - if (virStrToLong_i(start, NULL, 16, &func) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device function '%s'"), val); - goto error; - } - - def->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - def->managed =3D true; - def->source.subsys.type =3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI; - def->source.subsys.u.pci.addr.bus =3D bus; - def->source.subsys.u.pci.addr.slot =3D slot; - def->source.subsys.u.pci.addr.function =3D func; - return def; - - error: - virDomainHostdevDefFree(def); - return NULL; -} - - -/* - * Tries to parse a QEMU USB device - */ -static virDomainHostdevDefPtr -qemuParseCommandLineUSB(const char *val) -{ - virDomainHostdevDefPtr def =3D virDomainHostdevDefNew(); - virDomainHostdevSubsysUSBPtr usbsrc; - int first =3D 0, second =3D 0; - const char *start; - char *end; - - if (!def) - goto error; - usbsrc =3D &def->source.subsys.u.usb; - - if (!STRPREFIX(val, "host:")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown USB device syntax '%s'"), val); - goto error; - } - - start =3D val + strlen("host:"); - if (strchr(start, ':')) { - if (virStrToLong_i(start, &end, 16, &first) < 0 || *end !=3D ':') { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot extract USB device vendor '%s'"), val= ); - goto error; - } - start =3D end + 1; - if (virStrToLong_i(start, NULL, 16, &second) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot extract USB device product '%s'"), va= l); - goto error; - } - } else { - if (virStrToLong_i(start, &end, 10, &first) < 0 || *end !=3D '.') { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot extract USB device bus '%s'"), val); - goto error; - } - start =3D end + 1; - if (virStrToLong_i(start, NULL, 10, &second) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot extract USB device address '%s'"), va= l); - goto error; - } - } - - def->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - def->managed =3D false; - def->source.subsys.type =3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB; - if (*end =3D=3D '.') { - usbsrc->bus =3D first; - usbsrc->device =3D second; - } else { - usbsrc->vendor =3D first; - usbsrc->product =3D second; - } - return def; - - error: - virDomainHostdevDefFree(def); - return NULL; -} - - -/* - * Tries to parse a QEMU serial/parallel device - */ -static int -qemuParseCommandLineChr(virDomainChrSourceDefPtr source, - const char *val) -{ - if (STREQ(val, "null")) { - source->type =3D VIR_DOMAIN_CHR_TYPE_NULL; - } else if (STREQ(val, "vc")) { - source->type =3D VIR_DOMAIN_CHR_TYPE_VC; - } else if (STREQ(val, "pty")) { - source->type =3D VIR_DOMAIN_CHR_TYPE_PTY; - } else if (STRPREFIX(val, "file:")) { - source->type =3D VIR_DOMAIN_CHR_TYPE_FILE; - if (VIR_STRDUP(source->data.file.path, val + strlen("file:")) < 0) - goto error; - } else if (STRPREFIX(val, "pipe:")) { - source->type =3D VIR_DOMAIN_CHR_TYPE_PIPE; - if (VIR_STRDUP(source->data.file.path, val + strlen("pipe:")) < 0) - goto error; - } else if (STREQ(val, "stdio")) { - source->type =3D VIR_DOMAIN_CHR_TYPE_STDIO; - } else if (STRPREFIX(val, "udp:")) { - const char *svc1, *host2, *svc2; - source->type =3D VIR_DOMAIN_CHR_TYPE_UDP; - val +=3D strlen("udp:"); - svc1 =3D strchr(val, ':'); - host2 =3D svc1 ? strchr(svc1, '@') : NULL; - svc2 =3D host2 ? strchr(host2, ':') : NULL; - - if (svc1 && svc1 !=3D val && - VIR_STRNDUP(source->data.udp.connectHost, val, svc1 - val) < 0) - goto error; - - if (svc1) { - svc1++; - if (VIR_STRNDUP(source->data.udp.connectService, svc1, - host2 ? host2 - svc1 : strlen(svc1)) < 0) - goto error; - } - - if (host2) { - host2++; - if (svc2 && svc2 !=3D host2 && - VIR_STRNDUP(source->data.udp.bindHost, host2, svc2 - host2= ) < 0) - goto error; - } - - if (svc2) { - svc2++; - if (STRNEQ(svc2, "0")) { - if (VIR_STRDUP(source->data.udp.bindService, svc2) < 0) - goto error; - } - } - } else if (STRPREFIX(val, "tcp:") || - STRPREFIX(val, "telnet:")) { - const char *opt, *svc; - source->type =3D VIR_DOMAIN_CHR_TYPE_TCP; - if (STRPREFIX(val, "tcp:")) { - val +=3D strlen("tcp:"); - } else { - val +=3D strlen("telnet:"); - source->data.tcp.protocol =3D VIR_DOMAIN_CHR_TCP_PROTOCOL_TELN= ET; - } - svc =3D strchr(val, ':'); - if (!svc) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot find port number in character device = %s"), val); - goto error; - } - opt =3D strchr(svc, ','); - if (opt && strstr(opt, "server")) - source->data.tcp.listen =3D true; - - if (VIR_STRNDUP(source->data.tcp.host, val, svc - val) < 0) - goto error; - svc++; - if (VIR_STRNDUP(source->data.tcp.service, svc, opt ? opt - svc : -= 1) < 0) - goto error; - } else if (STRPREFIX(val, "unix:")) { - const char *opt; - val +=3D strlen("unix:"); - opt =3D strchr(val, ','); - source->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - if (VIR_STRNDUP(source->data.nix.path, val, opt ? opt - val : -1) = < 0) - goto error; - - } else if (STRPREFIX(val, "/dev")) { - source->type =3D VIR_DOMAIN_CHR_TYPE_DEV; - if (VIR_STRDUP(source->data.file.path, val) < 0) - goto error; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown character device syntax %s"), val); - goto error; - } - - return 0; - - error: - return -1; -} - - -static virCPUDefPtr -qemuInitGuestCPU(virDomainDefPtr dom) -{ - if (!dom->cpu) { - virCPUDefPtr cpu; - - if (VIR_ALLOC(cpu) < 0) - return NULL; - - cpu->type =3D VIR_CPU_TYPE_GUEST; - cpu->match =3D VIR_CPU_MATCH_EXACT; - dom->cpu =3D cpu; - } - - return dom->cpu; -} - - -static int -qemuParseCommandLineCPU(virDomainDefPtr dom, - const char *val) -{ - virCPUDefPtr cpu =3D NULL; - char **tokens; - char **hv_tokens =3D NULL; - char *model =3D NULL; - int ret =3D -1; - size_t i; - - if (!(tokens =3D virStringSplit(val, ",", 0))) - goto cleanup; - - if (tokens[0] =3D=3D NULL) - goto syntax; - - for (i =3D 0; tokens[i] !=3D NULL; i++) { - if (*tokens[i] =3D=3D '\0') - goto syntax; - - if (i =3D=3D 0) { - if (VIR_STRDUP(model, tokens[i]) < 0) - goto cleanup; - - if (STRNEQ(model, "qemu32") && STRNEQ(model, "qemu64")) { - if (!(cpu =3D qemuInitGuestCPU(dom))) - goto cleanup; - - cpu->model =3D model; - model =3D NULL; - } - } else if (*tokens[i] =3D=3D '+' || *tokens[i] =3D=3D '-') { - const char *feature =3D tokens[i] + 1; /* '+' or '-' */ - int policy; - - if (*tokens[i] =3D=3D '+') - policy =3D VIR_CPU_FEATURE_REQUIRE; - else - policy =3D VIR_CPU_FEATURE_DISABLE; - - if (*feature =3D=3D '\0') - goto syntax; - - if (!ARCH_IS_X86(dom->os.arch)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("%s platform doesn't support CPU features= '"), - virArchToString(dom->os.arch)); - goto cleanup; - } - - if (STREQ(feature, "kvmclock")) { - bool present =3D (policy =3D=3D VIR_CPU_FEATURE_REQUIRE); - size_t j; - - for (j =3D 0; j < dom->clock.ntimers; j++) { - if (dom->clock.timers[j]->name =3D=3D VIR_DOMAIN_TIMER= _NAME_KVMCLOCK) - break; - } - - if (j =3D=3D dom->clock.ntimers) { - virDomainTimerDefPtr timer; - if (VIR_ALLOC(timer) < 0 || - VIR_APPEND_ELEMENT_COPY(dom->clock.timers, - dom->clock.ntimers, timer)= < 0) { - VIR_FREE(timer); - goto cleanup; - } - timer->name =3D VIR_DOMAIN_TIMER_NAME_KVMCLOCK; - timer->present =3D present; - timer->tickpolicy =3D -1; - timer->track =3D -1; - timer->mode =3D -1; - } else if (dom->clock.timers[j]->present !=3D -1 && - dom->clock.timers[j]->present !=3D present) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("conflicting occurrences of kvmclock = feature")); - goto cleanup; - } - } else if (STREQ(feature, "kvm_pv_eoi")) { - if (policy =3D=3D VIR_CPU_FEATURE_REQUIRE) - dom->apic_eoi =3D VIR_TRISTATE_SWITCH_ON; - else - dom->apic_eoi =3D VIR_TRISTATE_SWITCH_OFF; - } else { - if (!cpu) { - if (!(cpu =3D qemuInitGuestCPU(dom))) - goto cleanup; - - cpu->model =3D model; - model =3D NULL; - } - - if (virCPUDefAddFeature(cpu, feature, policy) < 0) - goto cleanup; - } - } else if (STREQ(tokens[i], "hv_crash")) { - size_t j; - for (j =3D 0; j < dom->npanics; j++) { - if (dom->panics[j]->model =3D=3D VIR_DOMAIN_PANIC_MODEL_H= YPERV) - break; - } - - if (j =3D=3D dom->npanics) { - virDomainPanicDefPtr panic; - if (VIR_ALLOC(panic) < 0 || - VIR_APPEND_ELEMENT_COPY(dom->panics, - dom->npanics, panic) < 0) { - VIR_FREE(panic); - goto cleanup; - } - panic->model =3D VIR_DOMAIN_PANIC_MODEL_HYPERV; - } - } else if (STRPREFIX(tokens[i], "hv_")) { - const char *token =3D tokens[i] + 3; /* "hv_" */ - const char *feature, *value; - int f; - - if (*token =3D=3D '\0') - goto syntax; - - if (!(hv_tokens =3D virStringSplit(token, "=3D", 2))) - goto cleanup; - - feature =3D hv_tokens[0]; - value =3D hv_tokens[1]; - - if (*feature =3D=3D '\0') - goto syntax; - - dom->features[VIR_DOMAIN_FEATURE_HYPERV] =3D VIR_TRISTATE_SWIT= CH_ON; - - if ((f =3D virDomainHypervTypeFromString(feature)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported HyperV Enlightenment feature= " - "'%s'"), feature); - goto cleanup; - } - - switch ((virDomainHyperv) f) { - case VIR_DOMAIN_HYPERV_RELAXED: - case VIR_DOMAIN_HYPERV_VAPIC: - case VIR_DOMAIN_HYPERV_VPINDEX: - case VIR_DOMAIN_HYPERV_RUNTIME: - case VIR_DOMAIN_HYPERV_SYNIC: - case VIR_DOMAIN_HYPERV_STIMER: - case VIR_DOMAIN_HYPERV_RESET: - case VIR_DOMAIN_HYPERV_FREQUENCIES: - case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: - case VIR_DOMAIN_HYPERV_TLBFLUSH: - case VIR_DOMAIN_HYPERV_IPI: - case VIR_DOMAIN_HYPERV_EVMCS: - if (value) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("HyperV feature '%s' should not " - "have a value"), feature); - goto cleanup; - } - dom->hyperv_features[f] =3D VIR_TRISTATE_SWITCH_ON; - break; - - case VIR_DOMAIN_HYPERV_SPINLOCKS: - dom->hyperv_features[f] =3D VIR_TRISTATE_SWITCH_ON; - if (!value) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("missing HyperV spinlock retry count"= )); - goto cleanup; - } - - if (virStrToLong_ui(value, NULL, 0, &dom->hyperv_spinlocks= ) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("cannot parse HyperV spinlock retry c= ount")); - goto cleanup; - } - - if (dom->hyperv_spinlocks < 0xFFF) - dom->hyperv_spinlocks =3D 0xFFF; - break; - - case VIR_DOMAIN_HYPERV_VENDOR_ID: - dom->hyperv_features[f] =3D VIR_TRISTATE_SWITCH_ON; - if (!value) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("missing HyperV vendor_id value")); - goto cleanup; - } - - if (VIR_STRDUP(dom->hyperv_vendor_id, value) < 0) - goto cleanup; - - break; - - case VIR_DOMAIN_HYPERV_LAST: - break; - } - virStringListFree(hv_tokens); - hv_tokens =3D NULL; - } else if (STREQ(tokens[i], "kvm=3Doff")) { - dom->features[VIR_DOMAIN_FEATURE_KVM] =3D VIR_TRISTATE_SWITCH= _ON; - dom->kvm_features[VIR_DOMAIN_KVM_HIDDEN] =3D VIR_TRISTATE_SWI= TCH_ON; - } - } - - if (dom->os.arch =3D=3D VIR_ARCH_X86_64) { - bool is_32bit =3D false; - if (cpu) { - virCPUDataPtr cpuData =3D NULL; - - if (cpuEncode(VIR_ARCH_X86_64, cpu, NULL, &cpuData, - NULL, NULL, NULL, NULL) < 0) - goto cleanup; - - is_32bit =3D (virCPUDataCheckFeature(cpuData, "lm") !=3D 1); - virCPUDataFree(cpuData); - } else if (model) { - is_32bit =3D STREQ(model, "qemu32"); - } - - if (is_32bit) - dom->os.arch =3D VIR_ARCH_I686; - } - - ret =3D 0; - - cleanup: - VIR_FREE(model); - virStringListFree(tokens); - virStringListFree(hv_tokens); - return ret; - - syntax: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown CPU syntax '%s'"), val); - goto cleanup; -} - - -static int -qemuParseCommandLineMem(virDomainDefPtr dom, - const char *val) -{ - unsigned long long mem =3D 0; - unsigned long long size =3D 0; - unsigned long long maxmem =3D 0; - unsigned int slots =3D 0; - char *end; - size_t i; - int nkws; - char **kws; - char **vals; - int n; - int ret =3D -1; - - if (qemuParseKeywords(val, &kws, &vals, &nkws, 1) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse memory '%s'"), val); - goto cleanup; - } - - for (i =3D 0; i < nkws; i++) { - if (vals[i] =3D=3D NULL) { - if (i > 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse memory '%s'"), val); - goto cleanup; - } - if (virStrToLong_ull(kws[i], &end, 10, &mem) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse memory value '%s'"), kws[i]= ); - goto cleanup; - } - if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot scale memory: %s"), - virGetLastErrorMessage()); - goto cleanup; - } - - size =3D mem; - - } else { - if (STREQ(kws[i], "size") || STREQ(kws[i], "maxmem")) { - if (virStrToLong_ull(vals[i], &end, 10, &mem) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse memory value '%s'"), va= ls[i]); - goto cleanup; - } - if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0)= { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot scale memory: %s"), - virGetLastErrorMessage()); - goto cleanup; - } - - STREQ(kws[i], "size") ? (size =3D mem) : (maxmem =3D mem); - - } - if (STREQ(kws[i], "slots")) { - if (virStrToLong_i(vals[i], &end, 10, &n) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse slots value '%s'"), val= s[i]); - goto cleanup; - } - - slots =3D n; - - } - } - } - - virDomainDefSetMemoryTotal(dom, size / 1024); - dom->mem.cur_balloon =3D size / 1024; - dom->mem.memory_slots =3D slots; - dom->mem.max_memory =3D maxmem / 1024; - - ret =3D 0; - - cleanup: - qemuParseKeywordsFree(nkws, kws, vals); - return ret; -} - - -static int -qemuParseCommandLineSmp(virDomainDefPtr dom, - const char *val, - virDomainXMLOptionPtr xmlopt) -{ - unsigned int sockets =3D 0; - unsigned int cores =3D 0; - unsigned int threads =3D 0; - unsigned int maxcpus =3D 0; - unsigned int vcpus =3D 0; - size_t i; - int nkws; - char **kws; - char **vals; - int n; - char *end; - int ret; - - if (qemuParseKeywords(val, &kws, &vals, &nkws, 1) < 0) - return -1; - - for (i =3D 0; i < nkws; i++) { - if (vals[i] =3D=3D NULL) { - if (i > 0 || - virStrToLong_ui(kws[i], &end, 10, &vcpus) < 0 || *end !=3D= '\0') - goto syntax; - } else { - if (virStrToLong_i(vals[i], &end, 10, &n) < 0 || *end !=3D '\0= ') - goto syntax; - if (STREQ(kws[i], "sockets")) - sockets =3D n; - else if (STREQ(kws[i], "cores")) - cores =3D n; - else if (STREQ(kws[i], "threads")) - threads =3D n; - else if (STREQ(kws[i], "maxcpus")) - maxcpus =3D n; - else if (STREQ(kws[i], "cpus")) - vcpus =3D n; - else - goto syntax; - } - } - - if (sockets && cores && threads) { - virCPUDefPtr cpu; - - if (!(cpu =3D qemuInitGuestCPU(dom))) - goto error; - cpu->sockets =3D sockets; - cpu->cores =3D cores; - cpu->threads =3D threads; - } else if (sockets || cores || threads) { - goto syntax; - } - - if (maxcpus =3D=3D 0) { - if (cores) { - if (virDomainDefGetVcpusTopology(dom, &maxcpus) < 0) - goto error; - } else { - maxcpus =3D vcpus; - } - } - - if (maxcpus =3D=3D 0) - goto syntax; - - if (vcpus =3D=3D 0) - vcpus =3D maxcpus; - - if (virDomainDefSetVcpusMax(dom, maxcpus, xmlopt) < 0) - goto error; - - if (virDomainDefSetVcpus(dom, vcpus) < 0) - goto error; - - ret =3D 0; - - cleanup: - qemuParseKeywordsFree(nkws, kws, vals); - return ret; - - syntax: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse CPU topology '%s'"), val); - error: - ret =3D -1; - goto cleanup; -} - - -static void -qemuParseCommandLineBootDevs(virDomainDefPtr def, const char *str) -{ - int n, b =3D 0; - - for (n =3D 0; str[n] && b < VIR_DOMAIN_BOOT_LAST; n++) { - if (str[n] =3D=3D 'a') - def->os.bootDevs[b++] =3D VIR_DOMAIN_BOOT_FLOPPY; - else if (str[n] =3D=3D 'c') - def->os.bootDevs[b++] =3D VIR_DOMAIN_BOOT_DISK; - else if (str[n] =3D=3D 'd') - def->os.bootDevs[b++] =3D VIR_DOMAIN_BOOT_CDROM; - else if (str[n] =3D=3D 'n') - def->os.bootDevs[b++] =3D VIR_DOMAIN_BOOT_NET; - else if (str[n] =3D=3D ',') - break; - } - def->os.nBootDevs =3D b; -} - - -/* - * Analyse the env and argv settings and reconstruct a - * virDomainDefPtr representing these settings as closely - * as is practical. This is not an exact science.... - */ -static virDomainDefPtr -qemuParseCommandLine(virFileCachePtr capsCache, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - char **progenv, - char **progargv, - char **pidfile, - virDomainChrSourceDefPtr *monConfig, - bool *monJSON) -{ - virDomainDefPtr def =3D NULL; - size_t i; - bool nographics =3D false; - bool fullscreen =3D false; - char **list =3D NULL; - char *path; - size_t nnics =3D 0; - const char **nics =3D NULL; - int video =3D VIR_DOMAIN_VIDEO_TYPE_CIRRUS; - int nvirtiodisk =3D 0; - qemuDomainCmdlineDefPtr cmd =3D NULL; - virDomainDiskDefPtr disk =3D NULL; - const char *ceph_args =3D qemuFindEnv(progenv, "CEPH_ARGS"); - bool have_sdl =3D false; - virQEMUCapsPtr qemuCaps =3D NULL; - - if (pidfile) - *pidfile =3D NULL; - if (monConfig) - *monConfig =3D NULL; - if (monJSON) - *monJSON =3D false; - - if (!progargv[0]) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no emulator path found")); - return NULL; - } - - if (!(qemuCaps =3D virQEMUCapsCacheLookup(capsCache, progargv[0]))) - goto error; - - if (!(def =3D virDomainDefNew())) - goto error; - - /* allocate the cmdlinedef up-front; if it's unused, we'll free it lat= er */ - if (VIR_ALLOC(cmd) < 0) - goto error; - - if (virUUIDGenerate(def->uuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to generate uuid")); - goto error; - } - - def->id =3D -1; - def->mem.cur_balloon =3D 64 * 1024; - virDomainDefSetMemoryTotal(def, def->mem.cur_balloon); - if (virDomainDefSetVcpusMax(def, 1, xmlopt) < 0) - goto error; - if (virDomainDefSetVcpus(def, 1) < 0) - goto error; - def->clock.offset =3D VIR_DOMAIN_CLOCK_OFFSET_UTC; - - def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; - def->onCrash =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; - def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; - def->virtType =3D VIR_DOMAIN_VIRT_QEMU; - if (VIR_STRDUP(def->emulator, progargv[0]) < 0) - goto error; - - if (!(path =3D last_component(def->emulator))) - goto error; - - def->os.type =3D VIR_DOMAIN_OSTYPE_HVM; - if (strstr(path, "kvm")) { - def->virtType =3D VIR_DOMAIN_VIRT_KVM; - def->features[VIR_DOMAIN_FEATURE_PAE] =3D VIR_TRISTATE_SWITCH_ON; - } - - if (def->virtType =3D=3D VIR_DOMAIN_VIRT_KVM) - def->os.arch =3D caps->host.arch; - else if (STRPREFIX(path, "qemu-system-")) - def->os.arch =3D virArchFromString(path + strlen("qemu-system-")); - else - def->os.arch =3D VIR_ARCH_I686; - - if (ARCH_IS_X86(def->os.arch)) - def->features[VIR_DOMAIN_FEATURE_ACPI] =3D VIR_TRISTATE_SWITCH_ON; - -#define WANT_VALUE() \ - const char *val =3D progargv[++i]; \ - if (!val) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, \ - _("missing value for %s argument"), arg); \ - goto error; \ - } - - /* One initial loop to get list of NICs, so we - * can correlate them later */ - for (i =3D 1; progargv[i]; i++) { - const char *arg =3D progargv[i]; - /* Make sure we have a single - for all options to - simplify next logic */ - if (STRPREFIX(arg, "--")) - arg++; - - if (STREQ(arg, "-net")) { - WANT_VALUE(); - if (STRPREFIX(val, "nic") && - VIR_APPEND_ELEMENT(nics, nnics, val) < 0) - goto error; - } - } - - /* Detect machine type before processing any other arguments, - * because they might depend on it */ - for (i =3D 1; progargv[i]; i++) { - const char *arg =3D progargv[i]; - - /* Make sure we have a single - for all options to - simplify next logic */ - if (STRPREFIX(arg, "--")) - arg++; - - if (STREQ(arg, "-M") || - STREQ(arg, "-machine")) { - char *param; - size_t j =3D 0; - - /* -machine [type=3D]name[,prop[=3Dvalue][,...]] - * Set os.machine only if first parameter lacks '=3D' or - * contains explicit type=3D'...' */ - WANT_VALUE(); - if (!(list =3D virStringSplit(val, ",", 0))) - goto error; - param =3D list[0]; - - if (STRPREFIX(param, "type=3D")) - param +=3D strlen("type=3D"); - if (!strchr(param, '=3D')) { - if (VIR_STRDUP(def->os.machine, param) < 0) - goto error; - j++; - } - - /* handle all remaining "-machine" parameters */ - while ((param =3D list[j++])) { - if (STRPREFIX(param, "dump-guest-core=3D")) { - param +=3D strlen("dump-guest-core=3D"); - def->mem.dump_core =3D virTristateSwitchTypeFromString= (param); - if (def->mem.dump_core <=3D 0) - def->mem.dump_core =3D VIR_TRISTATE_SWITCH_ABSENT; - } else if (STRPREFIX(param, "mem-merge=3Doff")) { - def->mem.nosharepages =3D true; - } else if (STRPREFIX(param, "accel=3Dkvm")) { - def->virtType =3D VIR_DOMAIN_VIRT_KVM; - def->features[VIR_DOMAIN_FEATURE_PAE] =3D VIR_TRISTATE= _SWITCH_ON; - } else if (STRPREFIX(param, "aes-key-wrap=3D")) { - if (STREQ(arg, "-M")) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("aes-key-wrap is not supported wi= th " - "this QEMU binary")); - goto error; - } - param +=3D strlen("aes-key-wrap=3D"); - if (!def->keywrap && VIR_ALLOC(def->keywrap) < 0) - goto error; - def->keywrap->aes =3D virTristateSwitchTypeFromString(= param); - if (def->keywrap->aes < 0) - def->keywrap->aes =3D VIR_TRISTATE_SWITCH_ABSENT; - } else if (STRPREFIX(param, "dea-key-wrap=3D")) { - if (STREQ(arg, "-M")) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("dea-key-wrap is not supported wi= th " - "this QEMU binary")); - goto error; - } - param +=3D strlen("dea-key-wrap=3D"); - if (!def->keywrap && VIR_ALLOC(def->keywrap) < 0) - goto error; - def->keywrap->dea =3D virTristateSwitchTypeFromString(= param); - if (def->keywrap->dea < 0) - def->keywrap->dea =3D VIR_TRISTATE_SWITCH_ABSENT; - } - } - virStringListFree(list); - list =3D NULL; - } - } - - /* If no machine type has been found among the arguments, then figure - * out a reasonable value by using capabilities */ - if (!def->os.machine) { - const char *mach =3D virQEMUCapsGetDefaultMachine(qemuCaps); - - if (!mach) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Binary '%s' does not have a default machine = type " - "and no '-machine' arg is present"), - progargv[0]); - goto error; - } - - if (VIR_STRDUP(def->os.machine, mach) < 0) - goto error; - } - - /* Now the real processing loop */ - for (i =3D 1; progargv[i]; i++) { - const char *arg =3D progargv[i]; - bool argRecognized =3D true; - - /* Make sure we have a single - for all options to - simplify next logic */ - if (STRPREFIX(arg, "--")) - arg++; - - if (STREQ(arg, "-vnc")) { - WANT_VALUE(); - if (qemuParseCommandLineVnc(def, val) < 0) - goto error; - } else if (STREQ(arg, "-sdl")) { - have_sdl =3D true; - } else if (STREQ(arg, "-m")) { - WANT_VALUE(); - if (qemuParseCommandLineMem(def, val) < 0) - goto error; - } else if (STREQ(arg, "-smp")) { - WANT_VALUE(); - if (qemuParseCommandLineSmp(def, val, xmlopt) < 0) - goto error; - } else if (STREQ(arg, "-uuid")) { - WANT_VALUE(); - if (virUUIDParse(val, def->uuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, \ - _("cannot parse UUID '%s'"), val); - goto error; - } - } else if (STRPREFIX(arg, "-hd") || - STRPREFIX(arg, "-sd") || - STRPREFIX(arg, "-fd") || - STREQ(arg, "-cdrom")) { - WANT_VALUE(); - if (!(disk =3D virDomainDiskDefNew(xmlopt))) - goto error; - - if (STRPREFIX(val, "/dev/")) { - disk->src->type =3D VIR_STORAGE_TYPE_BLOCK; - } else if (STRPREFIX(val, "nbd:")) { - disk->src->type =3D VIR_STORAGE_TYPE_NETWORK; - disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_NBD; - } else if (STRPREFIX(val, "rbd:")) { - disk->src->type =3D VIR_STORAGE_TYPE_NETWORK; - disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_RBD; - val +=3D strlen("rbd:"); - } else if (STRPREFIX(val, "gluster")) { - disk->src->type =3D VIR_STORAGE_TYPE_NETWORK; - disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_GLUSTER; - } else if (STRPREFIX(val, "sheepdog:")) { - disk->src->type =3D VIR_STORAGE_TYPE_NETWORK; - disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_SHEEPDOG; - val +=3D strlen("sheepdog:"); - } else if (STRPREFIX(val, "vxhs:")) { - disk->src->type =3D VIR_STORAGE_TYPE_NETWORK; - disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_VXHS; - val +=3D strlen("vxhs:"); - } else { - disk->src->type =3D VIR_STORAGE_TYPE_FILE; - } - if (STREQ(arg, "-cdrom")) { - disk->device =3D VIR_DOMAIN_DISK_DEVICE_CDROM; - if (qemuDomainIsPSeries(def)) - disk->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; - if (VIR_STRDUP(disk->dst, "hdc") < 0) - goto error; - disk->src->readonly =3D true; - } else { - if (STRPREFIX(arg, "-fd")) { - disk->device =3D VIR_DOMAIN_DISK_DEVICE_FLOPPY; - disk->bus =3D VIR_DOMAIN_DISK_BUS_FDC; - } else { - disk->device =3D VIR_DOMAIN_DISK_DEVICE_DISK; - if (STRPREFIX(arg, "-hd")) - disk->bus =3D VIR_DOMAIN_DISK_BUS_IDE; - else - disk->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; - if (qemuDomainIsPSeries(def)) - disk->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; - } - if (VIR_STRDUP(disk->dst, arg + 1) < 0) - goto error; - } - if (VIR_STRDUP(disk->src->path, val) < 0) - goto error; - - if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { - char *port; - - switch ((virStorageNetProtocol) disk->src->protocol) { - case VIR_STORAGE_NET_PROTOCOL_NBD: - if (qemuParseNBDString(disk) < 0) - goto error; - break; - case VIR_STORAGE_NET_PROTOCOL_RBD: - /* old-style CEPH_ARGS env variable is parsed later */ - if (!ceph_args && qemuParseRBDString(disk) < 0) - goto error; - break; - case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: - /* disk->src must be [vdiname] or [host]:[port]:[vdina= me] */ - port =3D strchr(disk->src->path, ':'); - if (port) { - char *vdi; - - *port++ =3D '\0'; - vdi =3D strchr(port, ':'); - if (!vdi) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse sheepdog filena= me '%s'"), val); - goto error; - } - *vdi++ =3D '\0'; - if (VIR_ALLOC(disk->src->hosts) < 0) - goto error; - disk->src->nhosts =3D 1; - disk->src->hosts->name =3D disk->src->path; - if (virStringParsePort(port, &disk->src->hosts->po= rt) < 0) - goto error; - if (VIR_STRDUP(disk->src->path, vdi) < 0) - goto error; - } - break; - case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - if (qemuParseGlusterString(disk) < 0) - goto error; - - break; - case VIR_STORAGE_NET_PROTOCOL_ISCSI: - if (qemuParseISCSIString(disk) < 0) - goto error; - - break; - case VIR_STORAGE_NET_PROTOCOL_VXHS: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("VxHS protocol does not support URI " - "syntax '%s'"), disk->src->path); - goto error; - break; - case VIR_STORAGE_NET_PROTOCOL_HTTP: - case VIR_STORAGE_NET_PROTOCOL_HTTPS: - case VIR_STORAGE_NET_PROTOCOL_FTP: - case VIR_STORAGE_NET_PROTOCOL_FTPS: - case VIR_STORAGE_NET_PROTOCOL_TFTP: - case VIR_STORAGE_NET_PROTOCOL_SSH: - case VIR_STORAGE_NET_PROTOCOL_LAST: - case VIR_STORAGE_NET_PROTOCOL_NONE: - /* ignored for now */ - break; - } - } - - if (virDomainDiskDefAssignAddress(xmlopt, disk, def) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot assign address for device name '%= s'"), - disk->dst); - goto error; - } - - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - goto error; - } else if (STREQ(arg, "-no-acpi")) { - def->features[VIR_DOMAIN_FEATURE_ACPI] =3D VIR_TRISTATE_SWITCH= _ABSENT; - } else if (STREQ(arg, "-no-reboot")) { - def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; - } else if (STREQ(arg, "-no-kvm")) { - def->virtType =3D VIR_DOMAIN_VIRT_QEMU; - } else if (STREQ(arg, "-enable-kvm")) { - def->virtType =3D VIR_DOMAIN_VIRT_KVM; - } else if (STREQ(arg, "-nographic")) { - nographics =3D true; - } else if (STREQ(arg, "-display")) { - WANT_VALUE(); - if (STREQ(val, "none")) - nographics =3D true; - } else if (STREQ(arg, "-full-screen")) { - fullscreen =3D true; - } else if (STREQ(arg, "-localtime")) { - def->clock.offset =3D VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME; - } else if (STREQ(arg, "-kernel")) { - WANT_VALUE(); - if (VIR_STRDUP(def->os.kernel, val) < 0) - goto error; - } else if (STREQ(arg, "-bios")) { - WANT_VALUE(); - if (VIR_ALLOC(def->os.loader) < 0 || - VIR_STRDUP(def->os.loader->path, val) < 0) - goto error; - } else if (STREQ(arg, "-initrd")) { - WANT_VALUE(); - if (VIR_STRDUP(def->os.initrd, val) < 0) - goto error; - } else if (STREQ(arg, "-append")) { - WANT_VALUE(); - if (VIR_STRDUP(def->os.cmdline, val) < 0) - goto error; - } else if (STREQ(arg, "-dtb")) { - WANT_VALUE(); - if (VIR_STRDUP(def->os.dtb, val) < 0) - goto error; - } else if (STREQ(arg, "-boot")) { - const char *token =3D NULL; - WANT_VALUE(); - - if (!strchr(val, ',')) { - qemuParseCommandLineBootDevs(def, val); - } else { - token =3D val; - while (token && *token) { - if (STRPREFIX(token, "order=3D")) { - token +=3D strlen("order=3D"); - qemuParseCommandLineBootDevs(def, token); - } else if (STRPREFIX(token, "menu=3Don")) { - def->os.bootmenu =3D 1; - } else if (STRPREFIX(token, "reboot-timeout=3D")) { - int num; - char *endptr; - if (virStrToLong_i(token + strlen("reboot-timeout= =3D"), - &endptr, 10, &num) < 0 || - (*endptr !=3D '\0' && endptr !=3D strchr(token= , ','))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot parse reboot-timeout = value")); - goto error; - } - if (num > 65535) - num =3D 65535; - else if (num < -1) - num =3D -1; - def->os.bios.rt_delay =3D num; - def->os.bios.rt_set =3D true; - } - token =3D strchr(token, ','); - /* This incrementation has to be done here in order to= make it - * possible to pass the token pointer properly into th= e loop */ - if (token) - token++; - } - } - } else if (STREQ(arg, "-name")) { - char *process; - WANT_VALUE(); - process =3D strstr(val, ",process=3D"); - if (process =3D=3D NULL) { - if (VIR_STRDUP(def->name, val) < 0) - goto error; - } else { - if (VIR_STRNDUP(def->name, val, process - val) < 0) - goto error; - } - if (STREQ(def->name, "")) - VIR_FREE(def->name); - } else if (STREQ(arg, "-serial")) { - WANT_VALUE(); - if (STRNEQ(val, "none")) { - virDomainChrDefPtr chr; - - if (!(chr =3D virDomainChrDefNew(NULL))) - goto error; - - if (qemuParseCommandLineChr(chr->source, val) < 0) { - virDomainChrDefFree(chr); - goto error; - } - chr->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - chr->target.port =3D def->nserials; - if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) <= 0) { - virDomainChrDefFree(chr); - goto error; - } - } - } else if (STREQ(arg, "-parallel")) { - WANT_VALUE(); - if (STRNEQ(val, "none")) { - virDomainChrDefPtr chr; - - if (!(chr =3D virDomainChrDefNew(NULL))) - goto error; - - if (qemuParseCommandLineChr(chr->source, val) < 0) { - virDomainChrDefFree(chr); - goto error; - } - chr->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; - chr->target.port =3D def->nparallels; - if (VIR_APPEND_ELEMENT(def->parallels, def->nparallels, ch= r) < 0) { - virDomainChrDefFree(chr); - goto error; - } - } - } else if (STREQ(arg, "-usbdevice")) { - WANT_VALUE(); - if (STREQ(val, "tablet") || - STREQ(val, "mouse") || - STREQ(val, "keyboard")) { - virDomainInputDefPtr input; - if (VIR_ALLOC(input) < 0) - goto error; - input->bus =3D VIR_DOMAIN_INPUT_BUS_USB; - if (STREQ(val, "tablet")) - input->type =3D VIR_DOMAIN_INPUT_TYPE_TABLET; - else if (STREQ(val, "mouse")) - input->type =3D VIR_DOMAIN_INPUT_TYPE_MOUSE; - else - input->type =3D VIR_DOMAIN_INPUT_TYPE_KBD; - - if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) <= 0) { - virDomainInputDefFree(input); - goto error; - } - } else if (STRPREFIX(val, "disk:")) { - if (!(disk =3D virDomainDiskDefNew(xmlopt))) - goto error; - if (VIR_STRDUP(disk->src->path, val + strlen("disk:")) < 0) - goto error; - if (STRPREFIX(disk->src->path, "/dev/")) - disk->src->type =3D VIR_STORAGE_TYPE_BLOCK; - else - disk->src->type =3D VIR_STORAGE_TYPE_FILE; - disk->device =3D VIR_DOMAIN_DISK_DEVICE_DISK; - disk->bus =3D VIR_DOMAIN_DISK_BUS_USB; - disk->removable =3D VIR_TRISTATE_SWITCH_ABSENT; - if (VIR_STRDUP(disk->dst, "sda") < 0) - goto error; - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - goto error; - } else { - virDomainHostdevDefPtr hostdev; - if (!(hostdev =3D qemuParseCommandLineUSB(val))) - goto error; - if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, host= dev) < 0) { - virDomainHostdevDefFree(hostdev); - goto error; - } - } - } else if (STREQ(arg, "-net")) { - WANT_VALUE(); - if (!STRPREFIX(val, "nic") && STRNEQ(val, "none")) { - virDomainNetDefPtr net; - if (!(net =3D qemuParseCommandLineNet(xmlopt, val, nnics, = nics))) - goto error; - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) { - virDomainNetDefFree(net); - goto error; - } - } - } else if (STREQ(arg, "-drive")) { - WANT_VALUE(); - if (!(disk =3D qemuParseCommandLineDisk(xmlopt, val, def, - nvirtiodisk, - ceph_args !=3D NULL))) - goto error; - if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_VIRTIO) - nvirtiodisk++; - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - goto error; - } else if (STREQ(arg, "-pcidevice")) { - virDomainHostdevDefPtr hostdev; - WANT_VALUE(); - if (!(hostdev =3D qemuParseCommandLinePCI(val))) - goto error; - if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev)= < 0) { - virDomainHostdevDefFree(hostdev); - goto error; - } - } else if (STREQ(arg, "-soundhw")) { - const char *start; - WANT_VALUE(); - start =3D val; - while (start) { - const char *tmp =3D strchr(start, ','); - int type =3D -1; - if (STRPREFIX(start, "pcspk")) { - type =3D VIR_DOMAIN_SOUND_MODEL_PCSPK; - } else if (STRPREFIX(start, "sb16")) { - type =3D VIR_DOMAIN_SOUND_MODEL_SB16; - } else if (STRPREFIX(start, "es1370")) { - type =3D VIR_DOMAIN_SOUND_MODEL_ES1370; - } else if (STRPREFIX(start, "ac97")) { - type =3D VIR_DOMAIN_SOUND_MODEL_AC97; - } else if (STRPREFIX(start, "hda")) { - type =3D VIR_DOMAIN_SOUND_MODEL_ICH6; - } - - if (type !=3D -1) { - virDomainSoundDefPtr snd; - if (VIR_ALLOC(snd) < 0) - goto error; - snd->model =3D type; - if (VIR_APPEND_ELEMENT(def->sounds, def->nsounds, snd)= < 0) { - VIR_FREE(snd); - goto error; - } - } - - start =3D tmp ? tmp + 1 : NULL; - } - } else if (STREQ(arg, "-watchdog")) { - WANT_VALUE(); - int model =3D virDomainWatchdogModelTypeFromString(val); - - if (model !=3D -1) { - virDomainWatchdogDefPtr wd; - if (VIR_ALLOC(wd) < 0) - goto error; - wd->model =3D model; - wd->action =3D VIR_DOMAIN_WATCHDOG_ACTION_RESET; - def->watchdog =3D wd; - } - } else if (STREQ(arg, "-watchdog-action") && def->watchdog) { - WANT_VALUE(); - int action =3D virDomainWatchdogActionTypeFromString(val); - - if (action !=3D -1) - def->watchdog->action =3D action; - } else if (STREQ(arg, "-bootloader")) { - WANT_VALUE(); - if (VIR_STRDUP(def->os.bootloader, val) < 0) - goto error; - } else if (STREQ(arg, "-vmwarevga")) { - video =3D VIR_DOMAIN_VIDEO_TYPE_VMVGA; - } else if (STREQ(arg, "-std-vga")) { - video =3D VIR_DOMAIN_VIDEO_TYPE_VGA; - } else if (STREQ(arg, "-vga")) { - WANT_VALUE(); - if (STRNEQ(val, "none")) { - video =3D qemuVideoTypeFromString(val); - if (video < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown video adapter type '%s'"), v= al); - goto error; - } - } - } else if (STREQ(arg, "-cpu")) { - WANT_VALUE(); - if (qemuParseCommandLineCPU(def, val) < 0) - goto error; - } else if (STREQ(arg, "-domid")) { - WANT_VALUE(); - /* ignore, generted on the fly */ - } else if (STREQ(arg, "-usb")) { - if (virDomainDefAddUSBController(def, -1, -1) < 0) - goto error; - } else if (STREQ(arg, "-pidfile")) { - WANT_VALUE(); - if (pidfile) - if (VIR_STRDUP(*pidfile, val) < 0) - goto error; - } else if (STREQ(arg, "-incoming")) { - WANT_VALUE(); - /* ignore, used via restore/migrate APIs */ - } else if (STREQ(arg, "-monitor")) { - WANT_VALUE(); - if (monConfig) { - virDomainChrSourceDefPtr chr; - - if (!(chr =3D virDomainChrSourceDefNew(NULL))) - goto error; - - if (qemuParseCommandLineChr(chr, val) < 0) { - virObjectUnref(chr); - goto error; - } - - *monConfig =3D chr; - } - } else if (STREQ(arg, "-global") && - STRPREFIX(progargv[i + 1], "PIIX4_PM.disable_s3=3D")) { - /* We want to parse only the known "-global" parameters, - * so the ones that we don't know are still added to the - * namespace */ - WANT_VALUE(); - - val +=3D strlen("PIIX4_PM.disable_s3=3D"); - if (STREQ(val, "0")) { - def->pm.s3 =3D VIR_TRISTATE_BOOL_YES; - } else if (STREQ(val, "1")) { - def->pm.s3 =3D VIR_TRISTATE_BOOL_NO; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid value for disable_s3 parameter: " - "'%s'"), val); - goto error; - } - - } else if (STREQ(arg, "-global") && - STRPREFIX(progargv[i + 1], "PIIX4_PM.disable_s4=3D")) { - - WANT_VALUE(); - - val +=3D strlen("PIIX4_PM.disable_s4=3D"); - if (STREQ(val, "0")) { - def->pm.s4 =3D VIR_TRISTATE_BOOL_YES; - } else if (STREQ(val, "1")) { - def->pm.s4 =3D VIR_TRISTATE_BOOL_NO; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid value for disable_s4 parameter: " - "'%s'"), val); - goto error; - } - - } else if (STREQ(arg, "-global") && - STRPREFIX(progargv[i + 1], "spapr-nvram.reg=3D")) { - WANT_VALUE(); - - if (VIR_ALLOC(def->nvram) < 0) - goto error; - - def->nvram->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPR= VIO; - def->nvram->info.addr.spaprvio.has_reg =3D true; - - val +=3D strlen("spapr-nvram.reg=3D"); - if (virStrToLong_ull(val, NULL, 16, - &def->nvram->info.addr.spaprvio.reg) < 0)= { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse nvram's address '%s'"), val= ); - goto error; - } - } else if (STREQ(arg, "-S") || - STREQ(arg, "-nodefaults") || - STREQ(arg, "-nodefconfig")) { - /* ignore, always added by libvirt */ - } else if (STREQ(arg, "-device") && progargv[1 + 1]) { - const char *opts =3D progargv[i + 1]; - - /* NB: we can't do WANT_VALUE until we're sure that we - * recognize the device, otherwise the !argRecognized - * logic below will be messed up - */ - - if (STRPREFIX(opts, "virtio-balloon")) { - WANT_VALUE(); - if (VIR_ALLOC(def->memballoon) < 0) - goto error; - def->memballoon->model =3D VIR_DOMAIN_MEMBALLOON_MODEL_VIR= TIO; - } else { - /* add in new -device's here */ - - argRecognized =3D false; - } - } else if (STREQ(arg, "-M") || - STREQ(arg, "-machine")) { - /* This option has already been processed before entering this - * loop, so we just need to skip its argument and move along */ - WANT_VALUE(); - } else { - argRecognized =3D false; - } - - if (!argRecognized) { - char *tmp =3D NULL; - /* something we can't yet parse. Add it to the qemu namespace - * cmdline/environment advanced options and hope for the best - */ - VIR_WARN("unknown QEMU argument '%s', adding to the qemu names= pace", - arg); - if (VIR_STRDUP(tmp, arg) < 0 || - VIR_APPEND_ELEMENT(cmd->args, cmd->num_args, tmp) < 0) { - VIR_FREE(tmp); - goto error; - } - } - } - -#undef WANT_VALUE - if (def->ndisks > 0 && ceph_args) { - char *hosts, *port, *saveptr =3D NULL, *token; - virDomainDiskDefPtr first_rbd_disk =3D NULL; - for (i =3D 0; i < def->ndisks; i++) { - if (def->disks[i]->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && - def->disks[i]->src->protocol =3D=3D VIR_STORAGE_NET_PROTOC= OL_RBD) { - first_rbd_disk =3D def->disks[i]; - break; - } - } - - if (!first_rbd_disk) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("CEPH_ARGS was set without an rbd disk")); - goto error; - } - - /* CEPH_ARGS should be: -m host1[:port1][,host2[:port2]]... */ - if (!STRPREFIX(ceph_args, "-m ")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not parse CEPH_ARGS '%s'"), ceph_args); - goto error; - } - if (VIR_STRDUP(hosts, strchr(ceph_args, ' ') + 1) < 0) - goto error; - first_rbd_disk->src->nhosts =3D 0; - token =3D strtok_r(hosts, ",", &saveptr); - while (token !=3D NULL) { - if (VIR_REALLOC_N(first_rbd_disk->src->hosts, - first_rbd_disk->src->nhosts + 1) < 0) { - VIR_FREE(hosts); - goto error; - } - port =3D strchr(token, ':'); - if (port) { - *port++ =3D '\0'; - if (virStringParsePort(port, - &first_rbd_disk->src->hosts[first_r= bd_disk->src->nhosts].port) < 0) { - VIR_FREE(hosts); - goto error; - } - } - if (VIR_STRDUP(first_rbd_disk->src->hosts[first_rbd_disk->src-= >nhosts].name, - token) < 0) { - VIR_FREE(hosts); - goto error; - } - first_rbd_disk->src->hosts[first_rbd_disk->src->nhosts].transp= ort =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - first_rbd_disk->src->hosts[first_rbd_disk->src->nhosts].socket= =3D NULL; - - first_rbd_disk->src->nhosts++; - token =3D strtok_r(NULL, ",", &saveptr); - } - VIR_FREE(hosts); - - if (first_rbd_disk->src->nhosts =3D=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("found no rbd hosts in CEPH_ARGS '%s'"), ceph= _args); - goto error; - } - } - - if (!nographics && (def->ngraphics =3D=3D 0 || have_sdl)) { - virDomainGraphicsDefPtr sdl; - const char *display =3D qemuFindEnv(progenv, "DISPLAY"); - const char *xauth =3D qemuFindEnv(progenv, "XAUTHORITY"); - if (VIR_ALLOC(sdl) < 0) - goto error; - sdl->type =3D VIR_DOMAIN_GRAPHICS_TYPE_SDL; - sdl->data.sdl.fullscreen =3D fullscreen; - if (VIR_STRDUP(sdl->data.sdl.display, display) < 0) { - VIR_FREE(sdl); - goto error; - } - if (VIR_STRDUP(sdl->data.sdl.xauth, xauth) < 0) { - VIR_FREE(sdl); - goto error; - } - - if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, sdl) < 0) { - virDomainGraphicsDefFree(sdl); - goto error; - } - } - - if (def->ngraphics) { - virDomainVideoDefPtr vid; - if (!(vid =3D virDomainVideoDefNew())) - goto error; - vid->type =3D video; - - if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, vid) < 0) { - virDomainVideoDefFree(vid); - goto error; - } - } - - /* - * having a balloon is the default, define one with type=3D"none" to a= void it - */ - if (!def->memballoon) { - virDomainMemballoonDefPtr memballoon; - if (VIR_ALLOC(memballoon) < 0) - goto error; - memballoon->model =3D VIR_DOMAIN_MEMBALLOON_MODEL_NONE; - - def->memballoon =3D memballoon; - } - - VIR_FREE(nics); - - if (virDomainDefPostParse(def, caps, 0, xmlopt, NULL) < 0) - goto error; - - if (cmd->num_args || cmd->num_env) { - def->ns =3D *virDomainXMLOptionGetNamespace(xmlopt); - def->namespaceData =3D cmd; - } - else - qemuDomainCmdlineDefFree(cmd); - - virObjectUnref(qemuCaps); - return def; - - error: - virDomainDiskDefFree(disk); - qemuDomainCmdlineDefFree(cmd); - virDomainDefFree(def); - virStringListFree(list); - VIR_FREE(nics); - if (monConfig) { - virObjectUnref(*monConfig); - *monConfig =3D NULL; - } - if (pidfile) - VIR_FREE(*pidfile); - virObjectUnref(qemuCaps); - return NULL; -} - - -virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - const char *args, - char **pidfile, - virDomainChrSourceDefPtr *monCo= nfig, - bool *monJSON) -{ - char **progenv =3D NULL; - char **progargv =3D NULL; - virDomainDefPtr def =3D NULL; - - if (qemuStringToArgvEnv(args, &progenv, &progargv) < 0) - goto cleanup; - - def =3D qemuParseCommandLine(capsCache, caps, xmlopt, progenv, progarg= v, - pidfile, monConfig, monJSON); - - cleanup: - virStringListFree(progargv); - virStringListFree(progenv); - - return def; -} diff --git a/src/qemu/qemu_parse_command.h b/src/qemu/qemu_parse_command.h index 4dbb08fd59..e7af48e95b 100644 --- a/src/qemu/qemu_parse_command.h +++ b/src/qemu/qemu_parse_command.h @@ -22,22 +22,6 @@ #ifndef LIBVIRT_QEMU_PARSE_COMMAND_H # define LIBVIRT_QEMU_PARSE_COMMAND_H -# include "virfilecache.h" - -# define QEMU_QXL_VGAMEM_DEFAULT 16 * 1024 - -/* - * NB: def->name can be NULL upon return and the caller - * *must* decide how to fill in a name in this case - */ -virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - const char *args, - char **pidfile, - virDomainChrSourceDefPtr *monCo= nfig, - bool *monJSON); - void qemuParseKeywordsFree(int nkeywords, char **keywords, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list