mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-12 09:09:17 +00:00
util: iscsi: use two vars in CreateIfaceIQN
Do not mix automatic and manual cleanup. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1b5510c42d
commit
9abf18ace7
@ -208,7 +208,8 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
|||||||
int exitstatus = -1;
|
int exitstatus = -1;
|
||||||
g_autofree char *iface_name = NULL;
|
g_autofree char *iface_name = NULL;
|
||||||
g_autofree char *temp_ifacename = NULL;
|
g_autofree char *temp_ifacename = NULL;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) newcmd = NULL;
|
||||||
|
g_autoptr(virCommand) updatecmd = NULL;
|
||||||
|
|
||||||
temp_ifacename = g_strdup_printf("libvirt-iface-%08llx",
|
temp_ifacename = g_strdup_printf("libvirt-iface-%08llx",
|
||||||
(unsigned long long)virRandomBits(32));
|
(unsigned long long)virRandomBits(32));
|
||||||
@ -216,7 +217,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
|||||||
VIR_DEBUG("Attempting to create interface '%s' with IQN '%s'",
|
VIR_DEBUG("Attempting to create interface '%s' with IQN '%s'",
|
||||||
temp_ifacename, initiatoriqn);
|
temp_ifacename, initiatoriqn);
|
||||||
|
|
||||||
cmd = virCommandNewArgList(ISCSIADM,
|
newcmd = virCommandNewArgList(ISCSIADM,
|
||||||
"--mode", "iface",
|
"--mode", "iface",
|
||||||
"--interface", temp_ifacename,
|
"--interface", temp_ifacename,
|
||||||
"--op", "new",
|
"--op", "new",
|
||||||
@ -225,15 +226,14 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
|||||||
* tools returned an exit status of > 0, even if they succeeded.
|
* tools returned an exit status of > 0, even if they succeeded.
|
||||||
* We will just rely on whether the interface got created
|
* We will just rely on whether the interface got created
|
||||||
* properly. */
|
* properly. */
|
||||||
if (virCommandRun(cmd, &exitstatus) < 0) {
|
if (virCommandRun(newcmd, &exitstatus) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to run command '%s' to create new iscsi interface"),
|
_("Failed to run command '%s' to create new iscsi interface"),
|
||||||
ISCSIADM);
|
ISCSIADM);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
virCommandFree(cmd);
|
|
||||||
|
|
||||||
cmd = virCommandNewArgList(ISCSIADM,
|
updatecmd = virCommandNewArgList(ISCSIADM,
|
||||||
"--mode", "iface",
|
"--mode", "iface",
|
||||||
"--interface", temp_ifacename,
|
"--interface", temp_ifacename,
|
||||||
"--op", "update",
|
"--op", "update",
|
||||||
@ -244,7 +244,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
|||||||
/* Note that we ignore the exitstatus. Older versions of iscsiadm tools
|
/* Note that we ignore the exitstatus. Older versions of iscsiadm tools
|
||||||
* returned an exit status of > 0, even if they succeeded. We will just
|
* returned an exit status of > 0, even if they succeeded. We will just
|
||||||
* rely on whether iface file got updated properly. */
|
* rely on whether iface file got updated properly. */
|
||||||
if (virCommandRun(cmd, &exitstatus) < 0) {
|
if (virCommandRun(updatecmd, &exitstatus) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to run command '%s' to update iscsi interface with IQN '%s'"),
|
_("Failed to run command '%s' to update iscsi interface with IQN '%s'"),
|
||||||
ISCSIADM, initiatoriqn);
|
ISCSIADM, initiatoriqn);
|
||||||
|
Loading…
Reference in New Issue
Block a user