diff --git a/lib/backend.py b/lib/backend.py index 5ffeccbcfcf021f63a4a89f09ed007ae9e862e62..912cd8c18bfa943768d4999e029573f1f6d2ecb5 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1595,8 +1595,13 @@ def _WipeDevice(path, offset, size): @param size: The size in MiB to write """ + # Internal sizes are always in Mebibytes; if the following "dd" command + # should use a different block size the offset and size given to this + # function must be adjusted accordingly before being passed to "dd". + block_size = 1024 * 1024 + cmd = [constants.DD_CMD, "if=/dev/zero", "seek=%d" % offset, - "bs=%d" % constants.WIPE_BLOCK_SIZE, "oflag=direct", "of=%s" % path, + "bs=%s" % block_size, "oflag=direct", "of=%s" % path, "count=%d" % size] result = utils.RunCmd(cmd) @@ -1625,6 +1630,10 @@ def BlockdevWipe(disk, offset, size): _Fail("Cannot execute wipe for device %s: device not found", disk.iv_name) # Do cross verify some of the parameters + if offset < 0: + _Fail("Negative offset") + if size < 0: + _Fail("Negative size") if offset > rdev.size: _Fail("Offset is bigger than device size") if (offset + size) > rdev.size: diff --git a/lib/constants.py b/lib/constants.py index 6bb31a88d82ab4726e7f9ad3a13d928bb9651736..1d9787c97c4a585aa74fa54fcad967678d6bd8fe 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -129,7 +129,6 @@ CPU_PINNING_ALL_KVM = 0xFFFFFFFF # Wipe DD_CMD = "dd" -WIPE_BLOCK_SIZE = 1024 ** 2 MAX_WIPE_CHUNK = 1024 # 1GB MIN_WIPE_CHUNK_PERCENT = 10