On 10/12/2010 06:27 PM, David Lehman wrote:
This relies on a proposed patch to add dm_task_set_newuuid to libdevmapper and accompanying support in the kernel device-mapper layer.
This looks good.
Related: rhbz#584328 --- dm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 54 insertions(+), 1 deletions(-) diff --git a/dm.c b/dm.c index 8747cde..5daa0e5 100644 --- a/dm.c +++ b/dm.c @@ -1076,6 +1076,52 @@ pydm_map_set_name(PydmMapObject *map, const char *name) } static int +pydm_map_set_uuid(PydmMapObject *map, const char *uuid) +{ + struct dm_task *task; + int rc; + char *newuuid; + + rc = pydm_map_refresh(map); + if (rc< 0) + return rc; + + dm_log_init(pydm_log_fn); + task = dm_task_create(DM_DEVICE_RENAME); + if (!task) { + if (!PyErr_Occurred()) { + printf("%s: %d\n", __FILE__, __LINE__); + PyErr_NoMemory(); + } + dm_log_init(NULL); + return -1; + } + + newuuid = strdup(uuid); + if (!newuuid) { + dm_task_destroy(task); + dm_log_init(NULL); + printf("%s: %d\n", __FILE__, __LINE__); + PyErr_NoMemory(); + return -1; + } + + dm_task_set_name(task, map->name); + dm_task_set_newuuid(task, newuuid); + dm_task_run(task); + python_error_destroy_task(task, -1); + + dm_task_update_nodes(); + dm_task_destroy(task); + dm_log_init(NULL); + + free(map->uuid); + map->uuid = newuuid; + + return pydm_map_refresh(map); +} + +static int pydm_map_set_suspend(PydmMapObject *map, int suspend) { struct dm_task *task; @@ -1363,6 +1409,13 @@ pydm_map_set(PyObject *self, PyObject *value, void *data) return -1; return pydm_map_set_name(map, newname); + } else if (!strcmp(attr, "uuid")) { + char *newuuid = PyString_AsString(value); + + if (!newuuid || PyErr_Occurred()) + return -1; + + return pydm_map_set_uuid(map, newuuid); } else if (!strcmp(attr, "suspended")) { long suspended = value == Py_True ? 1 : 0; @@ -1389,7 +1442,7 @@ static struct PyGetSetDef pydm_map_getseters[] = { {"open_count", (getter)pydm_map_get, NULL, "open_count", "open_count"}, {"name", (getter)pydm_map_get, (setter)pydm_map_set, "name", "name"}, - {"uuid", (getter)pydm_map_get, NULL, "uuid", "uuid"}, + {"uuid", (getter)pydm_map_get, (setter)pydm_map_set, "uuid", "uuid"}, {"dev", (getter)pydm_map_get, pydm_map_set, "dev", "dev"}, {NULL}, };
-- Peter Computers have already beaten communists at chess. The next thing you know, they'll be beating humans. -- Dale 01234567890123456789012345678901234567890123456789012345678901234567890123456789 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list