}
+#define DEVPREFIX "/dev/"
+
#if defined(__linux__)
static int
qemuDomainCreateDevice(const char *device,
struct stat sb;
int ret = -1;
- if (!STRPREFIX(device, "/dev")) {
+ if (!STRPREFIX(device, DEVPREFIX)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid device: %s"),
device);
}
if (virAsprintf(&devicePath, "%s/%s",
- path, device + 4) < 0)
+ path, device + strlen(DEVPREFIX)) < 0)
goto cleanup;
if (stat(device, &sb) < 0) {
for (next = disk->src; next; next = next->backingStore) {
if (!next->path || !virStorageSourceIsLocalStorage(next) ||
- !STRPREFIX(next->path, "/dev")) {
+ !STRPREFIX(next->path, DEVPREFIX)) {
/* Not creating device. Just continue. */
continue;
}
for (next = disk->src; next; next = next->backingStore) {
if (!next->path || !virStorageSourceIsBlockLocal(disk->src) ||
- !STRPREFIX(next->path, "/dev")) {
+ !STRPREFIX(next->path, DEVPREFIX)) {
/* Not creating device. Just continue. */
continue;
}