Re: [PATCH] virtio-scsi: Add virtqueue_size parameter for qemu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 28, 2018 at 10:20:28PM +0300, Klim Kireev wrote:
In QEMU commit 5c0919d02066c3d0eb896c33265ad90101a6a84a
adds new option virtqueue_size. This Patch allows this option
to be set in libvirt.
---
docs/formatdomain.html.in |  6 ++++++
src/conf/domain_conf.c    | 12 ++++++++++++
src/conf/domain_conf.h    |  1 +
src/qemu/qemu_command.c   |  3 +++
4 files changed, 22 insertions(+)


The XML parser/formatter and the QEMU command line formatter additions
can be easily tested by extending genericxml2xmltest and
qemuxml2argvtest.

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6fd2189cd..2f33b5e70 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3867,6 +3867,12 @@
        host.
        <span class="since">Since 1.2.7 (QEMU and KVM only)</span>
      </dd>
+      <dt><code>virtqueue_size</code></dt>
+      <dd>
+        The optional <code>virtqueue_size</code> attribute specifies the size of
+        virtio queue.

Would be nice to mention why the user wants to set it (and to what
value).

Also, "queue_size" should be sufficient as the attribute name (and
increase the chance of us being able to reuse the attribute for
non-virtio controllers).

+        <span class="since">Since 3.7.0 (QEMU and KVM only)</span>

Libvirt 4.1.0 is already frozen, so the next release where this can
be merged is 4.2.0.

+      </dd>
      <dt><code>max_sectors</code></dt>
      <dd>
        The optional <code>max_sectors</code> attribute specifies the maximum
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d96b012b9..36a4deea2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9976,6 +9976,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
    char *model = NULL;
    char *queues = NULL;
    char *cmd_per_lun = NULL;
+    char *virtqueue_size = NULL;
    char *max_sectors = NULL;
    bool processedModel = false;
    char *modelName = NULL;
@@ -10035,6 +10036,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
                queues = virXMLPropString(cur, "queues");
                cmd_per_lun = virXMLPropString(cur, "cmd_per_lun");
                max_sectors = virXMLPropString(cur, "max_sectors");
+                virtqueue_size = virXMLPropString(cur, "virtqueue_size");
                ioeventfd = virXMLPropString(cur, "ioeventfd");
                iothread = virXMLPropString(cur, "iothread");

@@ -10089,6 +10091,12 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
        goto error;
    }

+    if (virtqueue_size && virStrToLong_ui(virtqueue_size, NULL, 10, &def->virtqueue_size) < 0) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Malformed 'virtqueue_size' value '%s'"), virtqueue_size);
+        goto error;
+    }
+
    if (max_sectors && virStrToLong_ui(max_sectors, NULL, 10, &def->max_sectors) < 0) {
        virReportError(VIR_ERR_XML_ERROR,
                       _("Malformed 'max_sectors' value %s"), max_sectors);
@@ -10310,6 +10318,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
    VIR_FREE(model);
    VIR_FREE(queues);
    VIR_FREE(cmd_per_lun);
+    VIR_FREE(virtqueue_size);
    VIR_FREE(max_sectors);
    VIR_FREE(modelName);
    VIR_FREE(chassisNr);
@@ -23293,6 +23302,9 @@ virDomainControllerDriverFormat(virBufferPtr buf,
    if (def->cmd_per_lun)
        virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun);

+    if (def->virtqueue_size)
+        virBufferAsprintf(&driverBuf, " virtqueue_size='%u'", def->virtqueue_size);
+
    if (def->max_sectors)
        virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors);

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 368f16f3f..141bd1aca 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -816,6 +816,7 @@ struct _virDomainControllerDef {
    int model; /* -1 == undef */
    unsigned int queues;
    unsigned int cmd_per_lun;
+    unsigned int virtqueue_size;
    unsigned int max_sectors;
    int ioeventfd; /* enum virTristateSwitch */
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fa0aa5d5c..9b1affd30 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2808,6 +2808,9 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
    if (def->queues)
        virBufferAsprintf(&buf, ",num_queues=%u", def->queues);

+    if (def->virtqueue_size)
+        virBufferAsprintf(&buf, ",virtqueue_size=%u", def->virtqueue_size);
+

If this option is not supported by the QEMU binary, it would be nice to
report an error before trying to run the domain.

See src/qemu/qemu_capabilities.c and qemuDomainDeviceDefValidateController

Jan

    if (def->cmd_per_lun)
        virBufferAsprintf(&buf, ",cmd_per_lun=%u", def->cmd_per_lun);

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux