Commit 201c0188 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

bdev_virtio: define virtio devs in separate config sections



This is required for adding
optional params for vdevs.

Since virtio-initiator README.md
had to be changed, some outdated
entries from TODO section has
been removed as a part of this
patch as well.

Change-Id: I472a966d8e4166305fb19ad3ab20e53289a1e071
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/382347


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent f062f797
Loading
Loading
Loading
Loading
+4 −16
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ Use the following configuration file snippet to enumerate a virtio-scsi PCI
device and present its LUNs as bdevs.

~~~{.sh}
[Virtio]
  Dev Pci
[VirtioPci]
  Enable Yes
~~~

Use the following configuration file snippet to enumerate an SPDK vhost-scsi
@@ -33,14 +33,11 @@ target has created an SPDK vhost-scsi controller which is accessible through
the /tmp/vhost.0 domain socket.

~~~{.sh}
[Virtio]
  Dev User /tmp/vhost.0
[VirtioUser0]
  Path /tmp/vhost.0
~~~

## Todo:
* Support multiple PCI devices, including specifying the PCI device by PCI
  bus/domain/function.
* Add unmap support.
* Add I/O channel support.  Includes requesting correct number of queues
  (based on core count).  Fail device initialization if not enough queues 
  can be allocated.
@@ -57,16 +54,7 @@ the /tmp/vhost.0 domain socket.
  scsi and blk.  If these should be separate, then this driver should be
  renamed to something scsi specific.
* Add reset support.
* Finish cleaning up "eth" references.  This includes filenames like
  virtio_ethdev.c and "eth" in various API calls.
* Understand and handle queue full conditions.
* Clear interrupt flag for completions - since we are polling, we do not
  need the virtio-scsi backend to signal completion.
* Check interrupt flag for submission.  If the backend requires an interrupt,
  we need to signal it.
* Change read/write to use READ_16/WRITE_16 to handle LBA > 4G.  We can add
  a basic check and bail during enumeration if INQUIRY indicates the LUN does
  not support >= SBC-3.
* Automated test scripts for both PCI and vhost-user scenarios.
* Document Virtio config file section in examples.  Should wait on this until
  enough of the above items are implemented to consider this module as ready
+60 −35
Original line number Diff line number Diff line
@@ -600,46 +600,75 @@ scan_target(struct virtio_scsi_scan_base *base)
}

static int
bdev_virtio_initialize(void)
bdev_virtio_process_config(void)
{
	struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "Virtio");
	struct virtio_scsi_scan_base *base;
	struct spdk_conf_section *sp;
	struct virtio_dev *vdev = NULL;
	char *type, *path;
	uint32_t i;
	char *path;
	unsigned vdev_num;
	bool enable_pci;
	int rc = 0;
	bool scan_pci = false;

	if (sp == NULL) {
		goto out;
	for (sp = spdk_conf_first_section(NULL); sp != NULL; sp = spdk_conf_next_section(sp)) {
		if (!spdk_conf_section_match_prefix(sp, "VirtioUser")) {
			continue;
		}

	for (i = 0; spdk_conf_section_get_nval(sp, "Dev", i) != NULL; i++) {
		type = spdk_conf_section_get_nmval(sp, "Dev", i, 0);
		if (type == NULL) {
			SPDK_ERRLOG("No type specified for index %d\n", i);
			continue;
		if (sscanf(spdk_conf_section_get_name(sp), "VirtioUser%u", &vdev_num) != 1) {
			SPDK_ERRLOG("Section '%s' has non-numeric suffix.\n",
				    spdk_conf_section_get_name(sp));
			rc = -1;
			goto out;
		}
		if (!strcmp("User", type)) {
			path = spdk_conf_section_get_nmval(sp, "Dev", i, 1);

		path = spdk_conf_section_get_val(sp, "Path");
		if (path == NULL) {
				SPDK_ERRLOG("No path specified for index %d\n", i);
				continue;
			SPDK_ERRLOG("VirtioUser%u: missing Path\n", vdev_num);
			rc = -1;
			goto out;
		}

		vdev = virtio_user_dev_init(path, 512);
		if (vdev == NULL) {
			rc = -1;
			goto out;
		}
		} else if (!strcmp("Pci", type)) {
			scan_pci = true;
		} else {
			SPDK_ERRLOG("Invalid type %s specified for index %d\n", type, i);
			continue;
	}

	sp = spdk_conf_find_section(NULL, "VirtioPci");
	if (sp == NULL) {
		return 0;
	}

	enable_pci = spdk_conf_section_get_boolval(sp, "Enable", false);
	if (enable_pci) {
		rc = vtpci_enumerate_pci();
	}

	return rc;
out:
	if (vdev) {
		virtio_dev_free(vdev);
	}
	return rc;
}


static int
bdev_virtio_initialize(void)
{
	struct virtio_scsi_scan_base *base;
	struct virtio_dev *vdev = NULL;
	int rc = 0;

	rc = bdev_virtio_process_config();
	if (rc != 0) {
		goto out;
	}

	if (scan_pci) {
		vtpci_enumerate_pci();
	if (TAILQ_EMPTY(&g_virtio_driver.init_ctrlrs)) {
		spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
		return 0;
	}

	TAILQ_FOREACH(vdev, &g_virtio_driver.init_ctrlrs, tailq) {
@@ -672,10 +701,6 @@ bdev_virtio_initialize(void)
	return 0;

out:
	if (vdev) {
		virtio_dev_free(vdev);
	}

	spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
	return rc;
}
+2 −2
Original line number Diff line number Diff line
[Virtio]
  Dev User /tmp/vhost.0
[VirtioUser0]
  Path /tmp/vhost.0

[Rpc]
  Enable Yes