58
58
ret = virStrToLong_ull(s, end_ptr, base, result);
60
VIR_ERROR("Failed to convert '%s' to unsigned long long", s);
60
VIR_ERROR(_("Failed to convert '%s' to unsigned long long"), s);
62
62
VIR_DEBUG("Converted '%s' to unsigned long %llu", s, *result);
76
76
ret = virStrToLong_ui(s, end_ptr, base, result);
78
VIR_ERROR("Failed to convert '%s' to unsigned int", s);
78
VIR_ERROR(_("Failed to convert '%s' to unsigned int"), s);
80
80
VIR_DEBUG("Converted '%s' to unsigned int %u", s, *result);
93
93
ret = virStrToLong_i(s, end_ptr, base, result);
95
VIR_ERROR("Failed to convert '%s' to int", s);
95
VIR_ERROR(_("Failed to convert '%s' to int"), s);
97
97
VIR_DEBUG("Converted '%s' to int %u", s, *result);
122
122
* of the function must also be changed. */
123
123
*property_value = strdup(udev_value);
124
124
if (*property_value == NULL) {
125
VIR_ERROR("Failed to allocate memory for property value for "
126
"property key '%s' on device with sysname '%s'",
125
VIR_ERROR(_("Failed to allocate memory for property value for "
126
"property key '%s' on device with sysname '%s'"),
127
127
property_key, udev_device_get_sysname(udev_device));
128
128
virReportOOMError();
129
129
ret = PROPERTY_ERROR;
211
211
* of the function must also be changed. */
212
212
*attr_value = strdup(udev_value);
213
213
if (*attr_value == NULL) {
214
VIR_ERROR("Failed to allocate memory for sysfs attribute value for "
215
"sysfs attribute '%s' on device with sysname '%s'",
214
VIR_ERROR(_("Failed to allocate memory for sysfs attribute value for "
215
"sysfs attribute '%s' on device with sysname '%s'"),
216
216
attr_name, udev_device_get_sysname(udev_device));
217
217
virReportOOMError();
218
218
ret = PROPERTY_ERROR;
330
330
if (virBufferError(&buf)) {
331
331
virBufferFreeAndReset(&buf);
332
VIR_ERROR("Buffer error when generating device name for device "
333
"with sysname '%s'", udev_device_get_sysname(device));
332
VIR_ERROR(_("Buffer error when generating device name for device "
333
"with sysname '%s'"), udev_device_get_sysname(device));
363
363
char **vendor_string,
364
364
char **product_string)
366
int ret = -1, pciret;
367
367
struct pci_id_match m;
368
368
const char *vendor_name = NULL, *device_name = NULL;
370
if (pci_system_init() != 0) {
371
VIR_ERROR0("Failed to initialize libpciaccess");
370
if ((pciret = pci_system_init()) != 0) {
372
VIR_INFO("Failed to initialize libpciaccess: %s",
373
virStrerror(pciret, ebuf, sizeof ebuf));
597
600
virNodeDeviceDefPtr def)
603
const char *devtype = udev_device_get_devtype(device);
600
604
union _virNodeDevCapData *data = &def->caps->data;
606
if (devtype && STREQ(devtype, "wlan")) {
607
data->net.subtype = VIR_NODE_DEV_CAP_NET_80211;
609
data->net.subtype = VIR_NODE_DEV_CAP_NET_80203;
602
612
if (udevGetStringProperty(device,
604
614
&data->net.ifname) == PROPERTY_ERROR) {
639
649
filename = basename(def->sysfs_path);
641
651
if (!STRPREFIX(filename, "host")) {
642
VIR_ERROR("SCSI host found, but its udev name '%s' does "
643
"not begin with 'host'", filename);
652
VIR_ERROR(_("SCSI host found, but its udev name '%s' does "
653
"not begin with 'host'"), filename);
1076
1086
devtype = udev_device_get_devtype(device);
1087
VIR_DEBUG("Found device type '%s' for device '%s'",
1088
NULLSTR(devtype), udev_device_get_sysname(device));
1078
1090
if (devtype != NULL && STREQ(devtype, "usb_device")) {
1079
1091
*type = VIR_NODE_DEV_CAP_USB_DEV;
1120
if (devtype != NULL && STREQ(devtype, "wlan")) {
1121
*type = VIR_NODE_DEV_CAP_NET;
1108
1125
if (udevGetUintProperty(device, "PCI_CLASS", &tmp, 16) == PROPERTY_FOUND) {
1109
1126
*type = VIR_NODE_DEV_CAP_PCI_DEV;
1113
/* It does not appear that network interfaces set the device type
1130
/* It does not appear that wired network interfaces set the
1131
* DEVTYPE property. USB devices also have an INTERFACE property,
1132
* but they do set DEVTYPE, so if devtype is NULL and the
1133
* INTERFACE property exists, we have a network device. */
1115
1134
if (devtype == NULL &&
1116
1135
udevGetStringProperty(device,
1165
1184
ret = udevProcessStorage(device, def);
1168
VIR_ERROR("Unknown device type %d", def->caps->type);
1187
VIR_ERROR(_("Unknown device type %d"), def->caps->type);
1207
1226
virNodeDeviceObjPtr dev = NULL;
1210
parent_device = udev_device_get_parent(device);
1211
if (parent_device == NULL) {
1212
VIR_INFO("Could not find udev parent for device with sysfs path '%s'",
1213
udev_device_get_syspath(device));
1216
parent_sysfs_path = udev_device_get_syspath(parent_device);
1217
if (parent_sysfs_path == NULL) {
1218
VIR_INFO("Could not get syspath for parent of '%s'",
1219
udev_device_get_syspath(device));
1220
parent_sysfs_path = "";
1223
def->parent_sysfs_path = strdup(parent_sysfs_path);
1224
if (def->parent_sysfs_path == NULL) {
1225
virReportOOMError();
1229
dev = virNodeDeviceFindBySysfsPath(&driverState->devs, parent_sysfs_path);
1229
parent_device = device;
1232
parent_device = udev_device_get_parent(parent_device);
1233
if (parent_device == NULL) {
1237
parent_sysfs_path = udev_device_get_syspath(parent_device);
1238
if (parent_sysfs_path == NULL) {
1239
VIR_INFO("Could not get syspath for parent of '%s'",
1240
udev_device_get_syspath(parent_device));
1243
dev = virNodeDeviceFindBySysfsPath(&driverState->devs,
1246
def->parent = strdup(dev->def->name);
1247
virNodeDeviceObjUnlock(dev);
1249
if (def->parent == NULL) {
1250
virReportOOMError();
1254
def->parent_sysfs_path = strdup(parent_sysfs_path);
1255
if (def->parent_sysfs_path == NULL) {
1256
virReportOOMError();
1262
} while (def->parent == NULL && parent_device != NULL);
1264
if (def->parent == NULL) {
1231
1265
def->parent = strdup("computer");
1233
def->parent = strdup(dev->def->name);
1234
virNodeDeviceObjUnlock(dev);
1237
1268
if (def->parent == NULL) {
1315
/* If this is a device change, the old definition will be freed
1316
* and the current definition will take its place. */
1284
1317
nodeDeviceLock(driverState);
1285
1318
dev = virNodeDeviceAssignDef(&driverState->devs, def);
1286
1319
nodeDeviceUnlock(driverState);
1288
1321
if (dev == NULL) {
1289
VIR_ERROR("Failed to create device for '%s'", def->name);
1290
virNodeDeviceDefFree(def);
1322
VIR_ERROR(_("Failed to create device for '%s'"), def->name);
1310
1346
name = udev_list_entry_get_name(list_entry);
1312
1348
device = udev_device_new_from_syspath(udev, name);
1313
1350
if (device != NULL) {
1314
1351
if (udevAddOneDevice(device) != 0) {
1315
1352
VIR_INFO("Failed to create node device for udev device '%s'",
1318
udev_device_unref(device);
1358
udev_device_unref(device);
1402
1440
udev_fd = udev_monitor_get_fd(udev_monitor);
1403
1441
if (fd != udev_fd) {
1404
VIR_ERROR("File descriptor returned by udev %d does not "
1405
"match node device file descriptor %d", fd, udev_fd);
1442
VIR_ERROR(_("File descriptor returned by udev %d does not "
1443
"match node device file descriptor %d"), fd, udev_fd);
1409
1447
device = udev_monitor_receive_device(udev_monitor);
1410
1448
if (device == NULL) {
1411
VIR_ERROR0("udev_monitor_receive_device returned NULL");
1449
VIR_ERROR0(_("udev_monitor_receive_device returned NULL"));
1443
1482
if (device == NULL) {
1444
1483
device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK);
1445
1484
if (device == NULL) {
1446
VIR_ERROR("Failed to get udev device for syspath '%s' or '%s'",
1485
VIR_ERROR(_("Failed to get udev device for syspath '%s' or '%s'"),
1447
1486
DMI_DEVPATH, DMI_DEVPATH_FALLBACK);
1476
if (udevGetStringSysfsAttr(device,
1478
&tmp) == PROPERTY_ERROR) {
1515
if (virGetHostUUID(data->system.hardware.uuid))
1481
virUUIDParse(tmp, data->system.hardware.uuid);
1483
1518
if (udevGetStringSysfsAttr(device,
1535
1570
dev = virNodeDeviceAssignDef(&driverState->devs, def);
1536
1571
if (dev == NULL) {
1537
VIR_ERROR("Failed to create device for '%s'", def->name);
1572
VIR_ERROR(_("Failed to create device for '%s'"), def->name);