From nobody Mon Feb 9 00:19:59 2026 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1562773640; cv=none; d=zoho.com; s=zohoarc; b=fXcYXb2NiAKsF2w7mvPIrHvq8HQGCqvSRt3eJqtV9ccwqzfWYyW64u7ULzsfoj/ZyCohS419zN8OrFhYUu0uD/f0SMvsfwQVTx88og264bAsloxK7VcXCivrB8KWA+YT/pBW6Xjeks5m2G5rNDnX5YaPmurZ3YgGnO55OpgWRwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562773640; 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=mvlbRw7GCt7EGD9dSyCrQ1bgYmQDDbEENW+D+xqmZtM=; b=dKouY/TD75/f6p6Z4KEUzHx6rT7qAJHc2hQzF8X3EJcEsoaMLspRb0FFqAsEk67+/Z+NMPhEaa3Ft3SNAdqBCyg8S3ApiuskiiWRhApadMWoeCEKMHMPHBxrhYKTsMqWs833u+QbdSFgJGqwxqx1NsvLNp7NQ3jMrqm/WyzangM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1562773640346120.33512298672588; Wed, 10 Jul 2019 08:47:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C0E130C1D06; Wed, 10 Jul 2019 15:47:18 +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 662F0BA114; Wed, 10 Jul 2019 15:47:18 +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 28CA2206D4; Wed, 10 Jul 2019 15:47:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6AFlGe0017716 for ; Wed, 10 Jul 2019 11:47:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CE161001DDD; Wed, 10 Jul 2019 15:47:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 844EB1001DDA for ; Wed, 10 Jul 2019 15:47:14 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B49803D97F for ; Wed, 10 Jul 2019 15:47:12 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id y4so3030176wrm.2 for ; Wed, 10 Jul 2019 08:47:12 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id r15sm2603408wrj.68.2019.07.10.08.47.09 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Jul 2019 08:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Yb6FmVUKZUiOwsaM3MB27gI8cLdODaqr4BdH/h6burc=; b=XB4vz4VhdpP9I7NUXSCc1q0rkusqAI2g3GIE0cV/goKoX/xqz5AELp915uP0oynp9q kQzoa8DYNPw2BEKyx+34e0Brx2bCUCkicPHnhwBKBsIvL8LX6o/nFx+4vumS9tkWXu3B /cMliT1rOYDK41k1nkBlasYvppQKVM2o/2SljISzQh8RcH051basWtQTWHjoYwB71e94 EyeuNZczWFIyUwKBcIh+J1AED75QqElnuQ3on6tayjIgY2roihoC/eXrMfY2Xi7xUWFF FCEB+itmYUIiSJEoNrpvw+rtFQNG9J6B7xxiPXALOinYFW825t+pm2atxy90wR7yh14g 3aMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yb6FmVUKZUiOwsaM3MB27gI8cLdODaqr4BdH/h6burc=; b=l8c6Jpcf5X53zP2TR0R0AV941UW2VQDAWGNEoCBpfmkk8T+Rk7Ed+uwShfeSQE1aYv pF9oXJO5xoclTuKP3R8nqf2uSexLHAb2hnJxTH4Cm5L9QeubqzGPqsvl7/oE82VKlEEM TgsPBdKAH5nGeNlCOuZ3yJwdhHG8ORD2v6PuC+dOj/4y/p+ZcouZB66qyM5Iq6JExRBP vNhHFsGFp8/lVWwUO39fHw7LtM5pfO97dqwi7wa4+uRdEGn+saAo97e4WnGEKoKxpZH+ 24N+chQDg6+9K/WDx4K11d1Tc9wN9/bT1KCXB2rNB/3+Xnm9qt0kQI61DnuVd7K5ct00 rW1A== X-Gm-Message-State: APjAAAUyvwFbOg5/G7+M1UeHJ9c3ROCS2aQagfW9MtIrhSHBnag0IS9t QO6d2eUKqRaZoFePbKn87+gxN09f/Io= X-Google-Smtp-Source: APXvYqzz97m9sRMo7Il07Sui5h9oZusPerFkcMxM2MSJcPgOELV8CnrSwm2zLyk42nvYrDg+tboZSw== X-Received: by 2002:a5d:4b91:: with SMTP id b17mr21954209wrt.57.1562773630753; Wed, 10 Jul 2019 08:47:10 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 10 Jul 2019 17:44:32 +0200 Message-Id: <20190710154431.30778-3-stamatis.iliass@gmail.com> In-Reply-To: <20190710154431.30778-1-stamatis.iliass@gmail.com> References: <20190710154431.30778-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 10 Jul 2019 15:47:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 10 Jul 2019 15:47:13 +0000 (UTC) for IP:'209.85.221.67' DOMAIN:'mail-wr1-f67.google.com' HELO:'mail-wr1-f67.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.194 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, PDS_NO_HELO_DNS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.221.67 mail-wr1-f67.google.com 209.85.221.67 mail-wr1-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] domain_conf: move DomainMergeBlkioDevice out of QEMU and LXC drivers 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 10 Jul 2019 15:47:19 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The qemuDomainMergeBlkioDevice and lxcDomainMergeBlkioDevice functions residing in the QEMU and LXC drivers respectively are completely identical. By moving the code to src/conf we avoid code duplication and we make the function available to other drivers that might need to call it such as the test driver. Signed-off-by: Ilias Stamatis --- src/conf/domain_conf.c | 70 ++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 7 ++++ src/libvirt_private.syms | 1 + src/lxc/lxc_driver.c | 72 +---------------------------------- src/qemu/qemu_driver.c | 81 +++------------------------------------- 5 files changed, 86 insertions(+), 145 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e10390189c..80e463cc3f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30334,6 +30334,76 @@ virDomainParseBlkioDeviceStr(char *blkioDeviceStr, } +/* Modify dest_array to reflect all blkio device changes described in + * src_array. */ +int +virDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array, + size_t *dest_size, + virBlkioDevicePtr src_array, + size_t src_size, + const char *type) +{ + size_t i, j; + virBlkioDevicePtr dest, src; + + for (i =3D 0; i < src_size; i++) { + bool found =3D false; + + src =3D &src_array[i]; + for (j =3D 0; j < *dest_size; j++) { + dest =3D &(*dest_array)[j]; + if (STREQ(src->path, dest->path)) { + found =3D true; + + if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { + dest->weight =3D src->weight; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS))= { + dest->riops =3D src->riops; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)= ) { + dest->wiops =3D src->wiops; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { + dest->rbps =3D src->rbps; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS))= { + dest->wbps =3D src->wbps; + } else { + virReportError(VIR_ERR_INVALID_ARG, _("Unknown paramet= er %s"), + type); + return -1; + } + break; + } + } + if (!found) { + if (!src->weight && !src->riops && !src->wiops && !src->rbps &= & !src->wbps) + continue; + if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0) + return -1; + dest =3D &(*dest_array)[*dest_size - 1]; + + if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { + dest->weight =3D src->weight; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) { + dest->riops =3D src->riops; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) { + dest->wiops =3D src->wiops; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { + dest->rbps =3D src->rbps; + } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) { + dest->wbps =3D src->wbps; + } else { + *dest_size =3D *dest_size - 1; + return -1; + } + + dest->path =3D src->path; + src->path =3D NULL; + } + } + + return 0; +} + + int virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def, virTypedParameterPtr params, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f31193b8d6..df02f60109 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3547,6 +3547,13 @@ virDomainGetBlkioParametersAssignFromDef(virDomainDe= fPtr def, int *nparams, int maxparams); +int +virDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array, + size_t *dest_size, + virBlkioDevicePtr src_array, + size_t src_size, + const char *type); + int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk, virDomainBlockIoTuneInfo *info); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5de3e6483f..a85c99525f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -455,6 +455,7 @@ virDomainMemoryModelTypeToString; virDomainMemoryRemove; virDomainMemorySourceTypeFromString; virDomainMemorySourceTypeToString; +virDomainMergeBlkioDevice; virDomainNetAllocateActualDevice; virDomainNetAppendIPAddress; virDomainNetBandwidthUpdate; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 0b3ca6a3ce..ad83cc94d7 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2102,74 +2102,6 @@ lxcDomainGetSchedulerParameters(virDomainPtr domain, return lxcDomainGetSchedulerParametersFlags(domain, params, nparams, 0= ); } -static int -lxcDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array, - size_t *dest_size, - virBlkioDevicePtr src_array, - size_t src_size, - const char *type) -{ - size_t i, j; - virBlkioDevicePtr dest, src; - - for (i =3D 0; i < src_size; i++) { - bool found =3D false; - - src =3D &src_array[i]; - for (j =3D 0; j < *dest_size; j++) { - dest =3D &(*dest_array)[j]; - if (STREQ(src->path, dest->path)) { - found =3D true; - - if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { - dest->weight =3D src->weight; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS))= { - dest->riops =3D src->riops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)= ) { - dest->wiops =3D src->wiops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { - dest->rbps =3D src->rbps; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS))= { - dest->wbps =3D src->wbps; - } else { - virReportError(VIR_ERR_INVALID_ARG, _("Unknown paramet= er %s"), - type); - return -1; - } - - break; - } - } - if (!found) { - if (!src->weight && !src->riops && !src->wiops && !src->rbps &= & !src->wbps) - continue; - if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0) - return -1; - dest =3D &(*dest_array)[*dest_size - 1]; - - if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { - dest->weight =3D src->weight; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) { - dest->riops =3D src->riops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) { - dest->wiops =3D src->wiops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { - dest->rbps =3D src->rbps; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) { - dest->wbps =3D src->wbps; - } else { - *dest_size =3D *dest_size - 1; - return -1; - } - - dest->path =3D src->path; - src->path =3D NULL; - } - } - - return 0; -} - static int lxcDomainBlockStats(virDomainPtr dom, @@ -2520,7 +2452,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, } if (j !=3D ndevices || - lxcDomainMergeBlkioDevice(&def->blkio.devices, + virDomainMergeBlkioDevice(&def->blkio.devices, &def->blkio.ndevices, devices, ndevices, param->fi= eld) < 0) ret =3D -1; @@ -2552,7 +2484,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, ret =3D -1; continue; } - if (lxcDomainMergeBlkioDevice(&persistentDef->blkio.device= s, + if (virDomainMergeBlkioDevice(&persistentDef->blkio.device= s, &persistentDef->blkio.ndevic= es, devices, ndevices, param->fi= eld) < 0) ret =3D -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a9e49501a7..d76941ee70 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9221,75 +9221,6 @@ static char *qemuDomainGetSchedulerType(virDomainPtr= dom, } -/* Modify dest_array to reflect all blkio device changes described in - * src_array. */ -static int -qemuDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array, - size_t *dest_size, - virBlkioDevicePtr src_array, - size_t src_size, - const char *type) -{ - size_t i, j; - virBlkioDevicePtr dest, src; - - for (i =3D 0; i < src_size; i++) { - bool found =3D false; - - src =3D &src_array[i]; - for (j =3D 0; j < *dest_size; j++) { - dest =3D &(*dest_array)[j]; - if (STREQ(src->path, dest->path)) { - found =3D true; - - if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { - dest->weight =3D src->weight; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS))= { - dest->riops =3D src->riops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)= ) { - dest->wiops =3D src->wiops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { - dest->rbps =3D src->rbps; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS))= { - dest->wbps =3D src->wbps; - } else { - virReportError(VIR_ERR_INVALID_ARG, _("Unknown paramet= er %s"), - type); - return -1; - } - break; - } - } - if (!found) { - if (!src->weight && !src->riops && !src->wiops && !src->rbps &= & !src->wbps) - continue; - if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0) - return -1; - dest =3D &(*dest_array)[*dest_size - 1]; - - if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { - dest->weight =3D src->weight; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) { - dest->riops =3D src->riops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) { - dest->wiops =3D src->wiops; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { - dest->rbps =3D src->rbps; - } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) { - dest->wbps =3D src->wbps; - } else { - *dest_size =3D *dest_size - 1; - return -1; - } - - dest->path =3D src->path; - src->path =3D NULL; - } - } - - return 0; -} - static int qemuDomainSetBlkioParameters(virDomainPtr dom, virTypedParameterPtr params, @@ -9449,9 +9380,9 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, } if (j !=3D ndevices || - qemuDomainMergeBlkioDevice(&def->blkio.devices, - &def->blkio.ndevices, - devices, ndevices, param->f= ield) < 0) + virDomainMergeBlkioDevice(&def->blkio.devices, + &def->blkio.ndevices, + devices, ndevices, param->fi= eld) < 0) ret =3D -1; virBlkioDeviceArrayClear(devices, ndevices); VIR_FREE(devices); @@ -9484,9 +9415,9 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, ret =3D -1; continue; } - if (qemuDomainMergeBlkioDevice(&persistentDef->blkio.devic= es, - &persistentDef->blkio.ndevi= ces, - devices, ndevices, param->f= ield) < 0) + if (virDomainMergeBlkioDevice(&persistentDef->blkio.device= s, + &persistentDef->blkio.ndevic= es, + devices, ndevices, param->fi= eld) < 0) ret =3D -1; virBlkioDeviceArrayClear(devices, ndevices); VIR_FREE(devices); -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list